Class: Facebookdp::OAuth
- Inherits:
-
Object
- Object
- Facebookdp::OAuth
- Defined in:
- lib/facebookdp/oauth.rb
Instance Attribute Summary collapse
-
#apikey ⇒ Object
Returns the value of attribute apikey.
-
#apisecret ⇒ Object
Returns the value of attribute apisecret.
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#code ⇒ Object
Returns the value of attribute code.
-
#graph_api_url ⇒ Object
Returns the value of attribute graph_api_url.
Instance Method Summary collapse
-
#authorize_url ⇒ Object
Get the url needed to recieve auth token behind the scenes, oauth2 is passing id and secret.
-
#client ⇒ Object
client is an instance of an oauth object, but needs to be authenticated by having a user visit facebook and retrieve a access code.
-
#get_access_token(code) ⇒ Object
Create access_token, and then we’re connected.
-
#initialize(apikey, apisecret, graph_api_url = "https://graph.facebook.com", callback_url = "http://localhost:3000/facebook/callback") ⇒ OAuth
constructor
A new instance of OAuth.
Constructor Details
#initialize(apikey, apisecret, graph_api_url = "https://graph.facebook.com", callback_url = "http://localhost:3000/facebook/callback") ⇒ OAuth
Returns a new instance of OAuth.
5 6 7 8 9 10 |
# File 'lib/facebookdp/oauth.rb', line 5 def initialize(apikey, apisecret, graph_api_url = "https://graph.facebook.com", callback_url = "http://localhost:3000/facebook/callback") @apikey = apikey @apisecret = apisecret @graph_api_url = graph_api_url @callback_url = callback_url end |
Instance Attribute Details
#apikey ⇒ Object
Returns the value of attribute apikey.
3 4 5 |
# File 'lib/facebookdp/oauth.rb', line 3 def apikey @apikey end |
#apisecret ⇒ Object
Returns the value of attribute apisecret.
3 4 5 |
# File 'lib/facebookdp/oauth.rb', line 3 def apisecret @apisecret end |
#callback_url ⇒ Object
Returns the value of attribute callback_url.
3 4 5 |
# File 'lib/facebookdp/oauth.rb', line 3 def callback_url @callback_url end |
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/facebookdp/oauth.rb', line 3 def code @code end |
#graph_api_url ⇒ Object
Returns the value of attribute graph_api_url.
3 4 5 |
# File 'lib/facebookdp/oauth.rb', line 3 def graph_api_url @graph_api_url end |
Instance Method Details
#authorize_url ⇒ Object
Get the url needed to recieve auth token behind the scenes, oauth2 is passing id and secret
23 24 25 |
# File 'lib/facebookdp/oauth.rb', line 23 def client.web_server.( :redirect_uri => callback_url ) end |
#client ⇒ Object
client is an instance of an oauth object, but needs to be authenticated by having a user visit facebook and retrieve a access code
16 17 18 |
# File 'lib/facebookdp/oauth.rb', line 16 def client @client ||= OAuth2::Client.new(@apikey, @apisecret, :site => @graph_api_url) end |
#get_access_token(code) ⇒ Object
Create access_token, and then we’re connected
29 30 31 32 |
# File 'lib/facebookdp/oauth.rb', line 29 def get_access_token(code) @code = code @access_token ||= client.web_server.get_access_token( @code, :redirect_uri => callback_url) end |