Class: RubyApp::Elements::Mobile::Documents::Authentication::OAuth::GitHubAuthenticationDocument

Inherits:
EmailAuthenticationDocument show all
Defined in:
lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb

Instance Attribute Summary

Attributes inherited from RubyApp::Elements::Mobile::Document

#links, #metadata, #pages, #scripts, #stylesheets

Attributes inherited from RubyApp::Element

#attributes

Instance Method Summary collapse

Methods inherited from EmailAuthenticationDocument

#create_identity_from_email

Methods inherited from AuthenticationDocument

#process_token

Methods inherited from RubyApp::Elements::Mobile::Document

#hide, #page, #show

Methods inherited from RubyApp::Element

#element_id, get_element

Methods included from Mixins::ConfigurationMixin

#configuration

Methods included from Mixins::TranslateMixin

#localize, #translate

Methods included from Mixins::TemplateMixin

#exclude_parent_template, #exclude_parent_template?, #get_cache, #get_default_template, #get_template, #get_template_name, #get_templates, #template_path

Methods included from Mixins::RenderMixin

#content_for, #get_cache, #get_default_template, #get_templates, #render

Constructor Details

#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 = {}) ⇒ GitHubAuthenticationDocument

Returns a new instance of GitHubAuthenticationDocument.



18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb', line 18

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

Instance Method Details

#create_identity_from_token(token) ⇒ Object



29
30
31
32
33
# File 'lib/ruby_app/elements/mobile/documents/authentication/o_auth/git_hub_authentication_document.rb', line 29

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