Class: OmniAuth::Strategies::GitHub
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::GitHub
- Defined in:
- lib/omniauth/strategies/github.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #callback_url ⇒ Object
- #email ⇒ Object
- #email_access_allowed? ⇒ Boolean
-
#emails ⇒ Object
The new /user/emails API - developer.github.com/v3/users/emails/#future-response.
- #primary_email ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
- #scope ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/omniauth/strategies/github.rb', line 16 def 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 ⇒ Object
77 78 79 |
# File 'lib/omniauth/strategies/github.rb', line 77 def callback_url full_host + callback_path end |
#email ⇒ Object
50 51 52 |
# File 'lib/omniauth/strategies/github.rb', line 50 def email (email_access_allowed?) ? primary_email : raw_info['email'] end |
#email_access_allowed? ⇒ Boolean
70 71 72 73 74 75 |
# File 'lib/omniauth/strategies/github.rb', line 70 def email_access_allowed? return false unless ['scope'] email_scopes = ['user', 'user:email'] scopes = ['scope'].split(',') (scopes & email_scopes).any? end |
#emails ⇒ Object
The new /user/emails API - developer.github.com/v3/users/emails/#future-response
64 65 66 67 68 |
# File 'lib/omniauth/strategies/github.rb', line 64 def emails return [] unless email_access_allowed? access_token.[:mode] = :header @emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed end |
#primary_email ⇒ Object
58 59 60 61 |
# 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 ⇒ Object
45 46 47 48 |
# File 'lib/omniauth/strategies/github.rb', line 45 def raw_info access_token.[:mode] = :header @raw_info ||= access_token.get('user').parsed end |
#request_phase ⇒ Object
12 13 14 |
# File 'lib/omniauth/strategies/github.rb', line 12 def request_phase super end |
#scope ⇒ Object
54 55 56 |
# File 'lib/omniauth/strategies/github.rb', line 54 def scope access_token['scope'] end |