class OmniAuth::Strategies::GitHub

Public Instance Methods

authorize_params() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/github.rb, line 16
def authorize_params
  super.tap do |params|
    %w[scope client_options].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
      end
    end
  end
end
callback_url() click to toggle source
# File lib/omniauth/strategies/github.rb, line 77
def callback_url
  full_host + callback_path
end
email() click to toggle source
# File lib/omniauth/strategies/github.rb, line 50
def email
  (email_access_allowed?) ? primary_email : raw_info['email']
end
email_access_allowed?() click to toggle source
# File lib/omniauth/strategies/github.rb, line 70
def email_access_allowed?
  return false unless options['scope']
  email_scopes = ['user', 'user:email']
  scopes = options['scope'].split(',')
  (scopes & email_scopes).any?
end
emails() click to toggle source

The new /user/emails API - developer.github.com/v3/users/emails/#future-response

# File lib/omniauth/strategies/github.rb, line 64
def emails
  return [] unless email_access_allowed?
  access_token.options[:mode] = :header
  @emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed
end
primary_email() click to toggle source
# File lib/omniauth/strategies/github.rb, line 58
def primary_email
  primary = emails.find{ |i| i['primary'] && i['verified'] }
  primary && primary['email'] || nil
end
raw_info() click to toggle source
# File lib/omniauth/strategies/github.rb, line 45
def raw_info
  access_token.options[:mode] = :header
  @raw_info ||= access_token.get('user').parsed
end
request_phase() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/github.rb, line 12
def request_phase
  super
end
scope() click to toggle source
# File lib/omniauth/strategies/github.rb, line 54
def scope
  access_token['scope']
end