Class: Foursquare::OAuth
- Inherits:
-
Object
- Object
- Foursquare::OAuth
- Defined in:
- lib/foursquare.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorize_from_access(atoken, asecret) ⇒ Object
- #authorize_from_request(request_token, request_secret, verifier) ⇒ Object
- #consumer ⇒ Object
-
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
constructor
A new instance of OAuth.
- #request_token(options = {}) ⇒ Object
- #set_callback_url(url) ⇒ Object
Constructor Details
#initialize(ctoken, csecret, options = {}) ⇒ OAuth
Returns a new instance of OAuth.
8 9 10 |
# File 'lib/foursquare.rb', line 8 def initialize(ctoken, csecret, ={}) @consumer_token, @consumer_secret = ctoken, csecret end |
Instance Method Details
#access_token ⇒ Object
40 41 42 |
# File 'lib/foursquare.rb', line 40 def access_token @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret) end |
#authorize_from_access(atoken, asecret) ⇒ Object
44 45 46 |
# File 'lib/foursquare.rb', line 44 def (atoken, asecret) @atoken, @asecret = atoken, asecret end |
#authorize_from_request(request_token, request_secret, verifier) ⇒ Object
34 35 36 37 38 |
# File 'lib/foursquare.rb', line 34 def (request_token, request_secret, verifier) request_token = ::OAuth::RequestToken.new(consumer, request_token, request_secret) access_token = request_token.get_access_token(:oauth_verifier => verifier) @atoken, @asecret = access_token.token, access_token.secret end |
#consumer ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/foursquare.rb', line 12 def consumer return @consumer if @consumer @consumer = ::OAuth::Consumer.new(@consumer_token, @consumer_secret, { :site => "http://foursquare.com", :scheme => :header, :http_method => :post, :request_token_path => "/oauth/request_token", :access_token_path => "/oauth/access_token", :authorize_path => "/oauth/authorize", :proxy => (ENV['HTTP_PROXY'] || ENV['http_proxy']) }) end |
#request_token(options = {}) ⇒ Object
30 31 32 |
# File 'lib/foursquare.rb', line 30 def request_token(={}) @request_token ||= consumer.get_request_token() end |
#set_callback_url(url) ⇒ Object
25 26 27 28 |
# File 'lib/foursquare.rb', line 25 def set_callback_url(url) clear_request_token request_token(:oauth_callback => url) end |