Class: OAuth::Google

Inherits:
Base
  • Object
show all
Defined in:
app/models/o_auth/google.rb

Constant Summary collapse

ACCESS_TOKEN_URL =
'https://accounts.google.com/o/oauth2/token'
DATA_URL =
'https://www.googleapis.com/plus/v1/people/me/openIdConnect'

Instance Attribute Summary

Attributes inherited from Base

#data, #provider

Instance Method Summary collapse

Methods inherited from Base

#get_data, #initialize

Constructor Details

This class inherits a constructor from OAuth::Base

Instance Method Details

#get_access_tokenObject

[View source]

6
7
8
9
10
# File 'app/models/o_auth/google.rb', line 6

def get_access_token
  response = @client.post(ACCESS_TOKEN_URL, @params.merge(grant_type: 'authorization_code'))
  
  JSON.parse(response.body)['access_token']
end

#get_namesObject

[View source]

12
13
14
15
16
# File 'app/models/o_auth/google.rb', line 12

def get_names
  names = data[:name].try(:split).to_a

  [data[:given_name] || names.first, data[:family_name] || names.last]
end