Class: RFGraph::Auth
- Inherits:
-
Object
- Object
- RFGraph::Auth
- Defined in:
- lib/rfgraph/auth.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
Returns the value of attribute app_secret.
-
#expires ⇒ Object
Returns the value of attribute expires.
Instance Method Summary collapse
- #authorize(callback_url, code) ⇒ Object
- #authorize_url(callback_url) ⇒ Object
-
#initialize(app_id, app_secret) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(app_id, app_secret) ⇒ Auth
Returns a new instance of Auth.
11 12 13 14 |
# File 'lib/rfgraph/auth.rb', line 11 def initialize(app_id, app_secret) @app_id = app_id @app_secret = app_secret end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/rfgraph/auth.rb', line 8 def access_token @access_token end |
#app_id ⇒ Object
Returns the value of attribute app_id.
6 7 8 |
# File 'lib/rfgraph/auth.rb', line 6 def app_id @app_id end |
#app_secret ⇒ Object
Returns the value of attribute app_secret.
7 8 9 |
# File 'lib/rfgraph/auth.rb', line 7 def app_secret @app_secret end |
#expires ⇒ Object
Returns the value of attribute expires.
9 10 11 |
# File 'lib/rfgraph/auth.rb', line 9 def expires @expires end |
Instance Method Details
#authorize(callback_url, code) ⇒ Object
20 21 22 23 24 |
# File 'lib/rfgraph/auth.rb', line 20 def (callback_url, code) data = open("#{BASE_URL}/oauth/access_token?client_id=#{app_id}&redirect_uri=#{CGI.escape callback_url}&client_secret=#{app_secret}&code=#{CGI.escape code}").read @expires = data.match(/expires=([^&]+)/)[1] @access_token = data.match(/access_token=([^&]+)/)[1] end |
#authorize_url(callback_url) ⇒ Object
16 17 18 |
# File 'lib/rfgraph/auth.rb', line 16 def (callback_url) "#{BASE_URL}/oauth/authorize?client_id=#{app_id}&redirect_uri=#{callback_url}" end |