Class: ApiUserAuth::Providers::Google
- Inherits:
-
Object
- Object
- ApiUserAuth::Providers::Google
- Defined in:
- lib/api_user_auth/providers/google.rb
Overview
Get info from Google token
Constant Summary collapse
- API_PATH =
'https://www.googleapis.com/plus/v1/people/me'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #api_info_url ⇒ Object
- #get_user_data ⇒ Object
-
#initialize(token) ⇒ Google
constructor
A new instance of Google.
- #user_data ⇒ Object
Constructor Details
#initialize(token) ⇒ Google
Returns a new instance of Google.
9 10 11 12 |
# File 'lib/api_user_auth/providers/google.rb', line 9 def initialize(token) @token = token @data = {} end |
Class Method Details
Instance Method Details
#api_info_url ⇒ Object
14 15 16 17 18 19 |
# File 'lib/api_user_auth/providers/google.rb', line 14 def api_info_url params = { access_token: @token } URI("#{API_PATH}?#{params.to_query}") end |
#get_user_data ⇒ Object
21 22 23 24 |
# File 'lib/api_user_auth/providers/google.rb', line 21 def get_user_data api_get_request user_data end |
#user_data ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api_user_auth/providers/google.rb', line 26 def user_data { id: @data[:id], name: @data[:displayName], email: @data[:emails].first.try(:[], :value), provider: 'google', img_url: (@data[:image] || {}).try(:[], :url), info: { birthday: @data[:birthday], city: (@data[:hometown] || {}).try(:[], :name), gender: @data[:gender] } } end |