Class: Metova::Oauth::GoogleProvider

Inherits:
GenericProvider show all
Defined in:
lib/metova/oauth/google_provider.rb

Constant Summary collapse

GOOGLE_API_URL =
'https://www.googleapis.com/plus/v1/people/me'
ME_URL =
-> (token) { "#{GOOGLE_API_URL}/me?access_token=#{token}" }

Instance Attribute Summary

Attributes inherited from GenericProvider

#access_token, #info, #token_secret, #uid

Instance Method Summary collapse

Methods inherited from GenericProvider

authenticate, #initialize

Constructor Details

This class inherits a constructor from Metova::Oauth::GenericProvider

Instance Method Details

#authenticateObject



7
8
9
10
11
# File 'lib/metova/oauth/google_provider.rb', line 7

def authenticate
  self.info = OmniAuth::AuthHash.new me
  self.uid = info.id
  self
end

#meObject



21
22
23
24
25
26
27
# File 'lib/metova/oauth/google_provider.rb', line 21

def me
  super do
    client = OAuth2
    token = OAuth2::AccessToken.new
    JSON.parse URI.parse(ME_URL[access_token]).read
  end
end

#nameObject



13
14
15
# File 'lib/metova/oauth/google_provider.rb', line 13

def name
  'Google'
end

#providerObject



17
18
19
# File 'lib/metova/oauth/google_provider.rb', line 17

def provider
  :google_oauth2
end