Module: Passport::Oauth::Authorizable::ClassMethods
- Defined in:
- lib/passport/oauth/client/authorizable.rb
Instance Method Summary collapse
-
#access(options) ⇒ Object
get the access token.
-
#authorize(callback_url, options = {}) ⇒ Object
first part in the sequece.
- #credentials ⇒ Object
Instance Method Details
#access(options) ⇒ Object
get the access token
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/passport/oauth/client/authorizable.rb', line 35 def access() if version == 1.0 access_token = OAuth::RequestToken.new(consumer, [:token], [:secret]).get_access_token(:oauth_verifier => [:oauth_verifier]) result = {:token => access_token.token.to_s, :secret => access_token.secret.to_s} else access_token = consumer.web_server.get_access_token([:secret], :redirect_uri => [:callback_url]) result = {:token => access_token.token.to_s, :secret => [:secret].to_s} end result[:key] = identify(access_token) unless [:identify] == false result end |
#authorize(callback_url, options = {}) ⇒ Object
first part in the sequece. returns a <Hash>:
{:url => "x", :token => "y", :secret => "z"}
if it’s using Oauth 1.0, token and secret will be present. if it’s using Oauth 2.0, token and secret are not present. for Oauth 1.0, save the token/secret in the session to use after the redirect.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/passport/oauth/client/authorizable.rb', line 17 def (callback_url, = {}) result = {} if version == 1.0 .reverse_merge!(:scope => consumer_settings[:scope]) if consumer_settings[:scope] request = consumer.get_request_token({:oauth_callback => callback_url}, ) result[:token] = request.token result[:secret] = request.secret result[:url] = request. else .merge!(:redirect_uri => callback_url) result[:url] = consumer.web_server.() end result end |
#credentials ⇒ Object
49 50 51 |
# File 'lib/passport/oauth/client/authorizable.rb', line 49 def credentials @credentials ||= Passport.credentials(service) end |