Class: OmniAuth::Strategies::GoogleOauth2

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

Overview

Main class for Google OAuth2 strategy.

Constant Summary collapse

ALLOWED_ISSUERS =
['accounts.google.com', 'https://accounts.google.com'].freeze
BASE_SCOPE_URL =
'https://www.googleapis.com/auth/'
BASE_SCOPES =
%w[profile email openid].freeze
DEFAULT_SCOPE =
'email,profile'
USER_INFO_URL =
'https://www.googleapis.com/oauth2/v3/userinfo'
IMAGE_SIZE_REGEXP =
/(s\d+(-c)?)|(w\d+-h\d+(-c)?)|(w\d+(-c)?)|(h\d+(-c)?)|c/
AUTHORIZE_OPTIONS =
%i[access_type hd login_hint prompt request_visible_actions scope state redirect_uri include_granted_scopes enable_granular_consent openid_realm device_id device_name]

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/omniauth/strategies/google_oauth2.rb', line 34

def authorize_params
  super.tap do |params|
    (options[:authorize_options] & options[:overridable_authorize_options]).each do |k|
      params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
    end

    params[:scope] = get_scope(params)
    params[:access_type] = 'offline' if params[:access_type].nil?
    params['openid.realm'] = params.delete(:openid_realm) unless params[:openid_realm].nil?

    session['omniauth.state'] = params[:state] if params[:state]
  end
end

#custom_build_access_tokenObject Also known as: build_access_token



101
102
103
104
105
106
# File 'lib/omniauth/strategies/google_oauth2.rb', line 101

def custom_build_access_token
  access_token = get_access_token(request)

  verify_hd(access_token)
  access_token
end

#raw_infoObject



97
98
99
# File 'lib/omniauth/strategies/google_oauth2.rb', line 97

def raw_info
  @raw_info ||= access_token.get(USER_INFO_URL).parsed
end