Class: OmniAuth::Strategies::GoogleOAuth2

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/google_oauth2.rb

Instance Method Summary collapse

Instance Method Details

#auth_hashObject



32
33
34
35
36
37
38
39
# File 'lib/omniauth/strategies/google_oauth2.rb', line 32

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid' => info['uid'],
    'info' => info,
    'credentials' => {'expires_at' => access_token.expires_at},
    'extra' => {'user_hash' => user_data}
  })
end

#request_phaseObject



14
15
16
17
# File 'lib/omniauth/strategies/google_oauth2.rb', line 14

def request_phase
  setup_authorize_params
  super
end

#setup_authorize_paramsObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/omniauth/strategies/google_oauth2.rb', line 19

def setup_authorize_params
  opts = {
    :client_id => options[:client_id],
    :redirect_uri => callback_url,
    :response_type => "code",
    :scope => options[:scope]
  }
  google_email_scope = "www.googleapis.com/auth/userinfo.email"
  opts[:scope] ||= "https://#{google_email_scope}"
  opts[:scope] << " https://#{google_email_scope}" unless opts[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}]
  options[:authorize_params] = opts.merge(options[:authorize_params])
end

#user_dataObject



55
56
57
# File 'lib/omniauth/strategies/google_oauth2.rb', line 55

def user_data
  @data ||= access_token.get("https://www.googleapis.com/userinfo/email?alt=json").parsed
end