Class: FacebookGraph::Authentication
- Inherits:
-
Object
- Object
- FacebookGraph::Authentication
- Includes:
- Helper
- Defined in:
- lib/facebook-graph/base/authentication.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
Instance Method Summary collapse
- #access_token(code) ⇒ Object
- #client_id_and_secret ⇒ Object
-
#initialize(client_id, client_secret, redirect_uri = nil) ⇒ Authentication
constructor
A new instance of Authentication.
- #user_authorization_uri(options = {}) ⇒ Object
Methods included from HTTPHelper
Constructor Details
#initialize(client_id, client_secret, redirect_uri = nil) ⇒ Authentication
Returns a new instance of Authentication.
4 5 6 7 |
# File 'lib/facebook-graph/base/authentication.rb', line 4 def initialize(client_id, client_secret, redirect_uri=nil) @client_id, @client_secret = client_id, client_secret @redirect_uri = redirect_uri end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
28 29 30 |
# File 'lib/facebook-graph/base/authentication.rb', line 28 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
28 29 30 |
# File 'lib/facebook-graph/base/authentication.rb', line 28 def client_secret @client_secret end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
29 30 31 |
# File 'lib/facebook-graph/base/authentication.rb', line 29 def redirect_uri @redirect_uri end |
Instance Method Details
#access_token(code) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/facebook-graph/base/authentication.rb', line 21 def access_token code config = FacebookGraph.configuration parse_form_data("#{config[:base_uri] + config[:access_token_uri]}?client_id=#{@client_id}" + "&client_secret=#{@client_secret}&code=#{CGI.escape(code)}" + "&redirect_uri=#{CGI.escape(@redirect_uri)}")['access_token'][0] end |
#client_id_and_secret ⇒ Object
9 10 11 |
# File 'lib/facebook-graph/base/authentication.rb', line 9 def client_id_and_secret [client_id, client_secret] end |
#user_authorization_uri(options = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/facebook-graph/base/authentication.rb', line 13 def (={}) config = FacebookGraph.configuration uri = "#{config[:base_uri] + config[:authorize_uri]}?client_id=#{@client_id}" uri += "&redirect_uri=#{CGI.escape(@redirect_uri)}" if @redirect_uri uri += "&#{hash_to_querystring()}" unless .nil? || .empty? uri end |