Module: Teambox::OAuth
- Included in:
- Client
- Defined in:
- lib/teambox-client/teambox_oauth.rb
Overview
Methods used to authenticate with OAuth on teambox.com. Normally you won’t have to call these.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#authorize_from_access ⇒ Object
Authorizes the client from an existing OAuth token.
- #authorize_from_request(verifier) ⇒ Object
-
#authorized? ⇒ Boolean
Is the client authorized via OAuth?.
-
#consumer ⇒ Object
OAuth consumer required for authentication.
- #consumer_url ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
4 5 6 |
# File 'lib/teambox-client/teambox_oauth.rb', line 4 def access_token @access_token end |
Instance Method Details
#authorize_from_access ⇒ Object
Authorizes the client from an existing OAuth token
33 34 35 |
# File 'lib/teambox-client/teambox_oauth.rb', line 33 def @access_token = ::OAuth2::AccessToken.new(nil, @auth[:oauth_token]) end |
#authorize_from_request(verifier) ⇒ Object
26 27 28 29 30 |
# File 'lib/teambox-client/teambox_oauth.rb', line 26 def (verifier) @access_token = consumer.web_server.get_access_token(verifier, :redirect_uri => @auth[:redirect_uri], :grant_type => 'authorization_code') @auth[:oauth_token] = @access_token.token @access_token end |
#authorized? ⇒ Boolean
Is the client authorized via OAuth?
22 23 24 |
# File 'lib/teambox-client/teambox_oauth.rb', line 22 def !@access_token.nil? end |
#consumer ⇒ Object
OAuth consumer required for authentication
7 8 9 10 11 12 13 |
# File 'lib/teambox-client/teambox_oauth.rb', line 7 def consumer return nil if @auth[:oauth_app_id].nil? @consumer ||= OAuth2::Client.new(@auth[:oauth_app_id], @auth[:oauth_app_secret], :site => consumer_url, :access_token_path => consumer_url+'oauth/token', :authorize_path => consumer_url+'oauth/authorize?response_type=code') end |
#consumer_url ⇒ Object
15 16 17 18 19 |
# File 'lib/teambox-client/teambox_oauth.rb', line 15 def consumer_url uri = URI.parse(self.class.base_uri) uri.path = '/' uri.to_s end |