Class: Metova::Oauth::FacebookProvider

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

Constant Summary collapse

FACEBOOK_API_URL =
'https://graph.facebook.com/v2.6'
ME_URL =
-> (token) { "#{FACEBOOK_API_URL}/me?fields=name,email&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/facebook_provider.rb', line 7

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

#meObject



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

def me
  super do
    JSON.parse URI.parse(ME_URL[access_token]).read
  end
end

#nameObject



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

def name
  'Facebook'
end

#providerObject



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

def provider
  :facebook
end