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

BASE_SCOPE_URL =
'https://www.googleapis.com/auth/'
BASE_SCOPES =
%w[profile email openid].freeze
DEFAULT_SCOPE =
'email,profile'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



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

def authorize_params
  super.tap do |params|
    options[: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



93
94
95
96
97
98
# File 'lib/omniauth/strategies/google_oauth2.rb', line 93

def custom_build_access_token
  access_token = get_access_token(request)

  verify_hd(access_token)
  access_token
end

#raw_friend_info(id) ⇒ Object



85
86
87
# File 'lib/omniauth/strategies/google_oauth2.rb', line 85

def raw_friend_info(id)
  @raw_friend_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}/people/visible").parsed
end

#raw_image_info(id) ⇒ Object



89
90
91
# File 'lib/omniauth/strategies/google_oauth2.rb', line 89

def raw_image_info(id)
  @raw_image_info ||= access_token.get("https://www.googleapis.com/plus/v1/people/#{id}?fields=image").parsed
end

#raw_infoObject



81
82
83
# File 'lib/omniauth/strategies/google_oauth2.rb', line 81

def raw_info
  @raw_info ||= access_token.get('https://www.googleapis.com/plus/v1/people/me/openIdConnect').parsed
end