Class: OmniAuth::Strategies::Google2

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

Overview

OmniAuth strategy for Google OAuth2/OpenID Connect.

Direct Known Subclasses

GoogleOauth2

Constant Summary collapse

BASE_SCOPE_URL =
"https://www.googleapis.com/auth/"
BASE_SCOPES =
%w[openid email profile].freeze
DEFAULT_SCOPE =
"openid email profile"
USER_INFO_URL =
"https://openidconnect.googleapis.com/v1/userinfo"

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



69
70
71
72
73
74
75
76
77
# File 'lib/omniauth/strategies/google2.rb', line 69

def authorize_params
  super.tap do |params|
    apply_request_authorize_overrides(params)
    params[:scope] = normalize_scope(params[:scope] || options[:scope])
    params[:access_type] ||= "offline"
    params[:include_granted_scopes] = normalize_include_granted_scopes(params[:include_granted_scopes])
    persist_authorize_state(params)
  end
end

#callback_urlObject

Ensure token exchange uses a stable callback URI that matches provider config.



84
85
86
# File 'lib/omniauth/strategies/google2.rb', line 84

def callback_url
  options[:callback_url] || options[:redirect_uri] || super
end

#query_stringObject

Prevent authorization response params from being appended to redirect_uri.



89
90
91
92
93
# File 'lib/omniauth/strategies/google2.rb', line 89

def query_string
  return "" if request.params["code"]

  super
end

#raw_infoObject



79
80
81
# File 'lib/omniauth/strategies/google2.rb', line 79

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