Sha256: 0e48aea7f91a1364a25a7bb05a0c37a2200f66de960406878a9dcad2f7696d77

Contents?: true

Size: 1.89 KB

Versions: 16

Compression:

Stored size: 1.89 KB

Contents

module RubyApp

  module Elements

    module Mobile

      module Documents

        module Authentication

          module OAuth
            require 'ruby_app/elements/mobile/documents/authentication/o_auth/email_authentication_document'

            class GitHubAuthenticationDocument < RubyApp::Elements::Mobile::Documents::Authentication::OAuth::EmailAuthenticationDocument

              template_path(:all, File.dirname(__FILE__))

              def initialize(access_key = ENV['GITHUB_ACCESS_KEY'] || RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument.configuration.access_key,
                             secret_key = ENV['GITHUB_SECRET_KEY'] || RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument.configuration.secret_key,
                             scopes      = [],
                             options    = {})
                _scopes = scopes.is_a?(Array) ? ( ['user'] + scopes ) : ( "user,#{scopes}")
                _options = {:site           => RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument.configuration.url,
                            :authorize_url  => RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument.configuration.authorize_url,
                            :token_url      => RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument.configuration.access_token_url}.merge(options)
                super(access_key, secret_key, _scopes, _options)
              end

              def create_identity_from_token(token)
                user = JSON.parse(token.get('/user').body)
                # RubyApp::Log.debug("GITHUB    user=#{user.inspect}")
                return self.create_identity_from_email(user['email'])
              end

            end

          end

        end

      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
RubyApp-0.7.16 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.15 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.14 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.13 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.12 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.11 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.10 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.9 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.5 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.4 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.3 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.2 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.1 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.7.0 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.6.71 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb
RubyApp-0.6.70 lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb