Class: Foursquared::OAuth::Client
- Inherits:
-
Object
- Object
- Foursquared::OAuth::Client
- Defined in:
- lib/foursquared/oauth/client.rb
Overview
OAuth Client class
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#oauth_client ⇒ Object
Returns the value of attribute oauth_client.
Instance Method Summary collapse
-
#authorize_url ⇒ String
Step 1: URL for OAuth2 oauthorizetion of Foursquare.
-
#get_access_token(code) ⇒ String
Step 2: Get access token after authorizing user.
-
#initialize(client_id, client_secret, callback_url, opts = {}, &block) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(client_id, client_secret, callback_url, opts = {}, &block) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/foursquared/oauth/client.rb', line 8 def initialize(client_id, client_secret, callback_url, opts={}, &block) @client_id = client_id @client_secret = client_secret @callback_url = callback_url ssl = opts.delete(:ssl) @options = { :site => 'https://foursquare.com/', :authorize_url => '/oauth2/authenticate?response_type=code', :token_url => '/oauth2/access_token', :parse_json => true}.merge(opts) @options[:connection_opts][:ssl] = ssl if ssl @oauth_client = OAuth2::Client.new(client_id, client_secret, @options) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
7 8 9 |
# File 'lib/foursquared/oauth/client.rb', line 7 def access_token @access_token end |
#callback_url ⇒ Object
Returns the value of attribute callback_url.
7 8 9 |
# File 'lib/foursquared/oauth/client.rb', line 7 def callback_url @callback_url end |
#client_id ⇒ Object
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/foursquared/oauth/client.rb', line 7 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
7 8 9 |
# File 'lib/foursquared/oauth/client.rb', line 7 def client_secret @client_secret end |
#oauth_client ⇒ Object
Returns the value of attribute oauth_client.
7 8 9 |
# File 'lib/foursquared/oauth/client.rb', line 7 def oauth_client @oauth_client end |
Instance Method Details
#authorize_url ⇒ String
Step 1: URL for OAuth2 oauthorizetion of Foursquare
25 26 27 |
# File 'lib/foursquared/oauth/client.rb', line 25 def oauth_client.auth_code.(:redirect_uri => callback_url) end |
#get_access_token(code) ⇒ String
Step 2: Get access token after authorizing user
32 33 34 35 |
# File 'lib/foursquared/oauth/client.rb', line 32 def get_access_token code token = oauth_client.auth_code.get_token(code, :redirect_uri => callback_url) @access_token = token.token end |