Class: Openlive::OAuth
- Inherits:
-
Object
- Object
- Openlive::OAuth
- Defined in:
- lib/openlive/oauth.rb
Instance Attribute Summary collapse
-
#current_token ⇒ OAuth2::AccessToken
Used to store the existing token.
Instance Method Summary collapse
-
#client ⇒ OAuth2::Client
Return or instantiate the OAuth client.
-
#requisition_token ⇒ OAuth2::AccessToken
Fetch a new token from the OAuth server.
-
#token ⇒ OAuth2::AccessToken
Return an existing unexpired token for this OAuth instance or requisition a new one from the server.
Instance Attribute Details
#current_token ⇒ OAuth2::AccessToken
Returns Used to store the existing token.
7 8 9 |
# File 'lib/openlive/oauth.rb', line 7 def current_token @current_token end |
Instance Method Details
#client ⇒ OAuth2::Client
Return or instantiate the OAuth client
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/openlive/oauth.rb', line 13 def client @client ||= ( credentials = Openlive.configuration.oauth_credentials OAuth2::Client.new( credentials[:client_id], credentials[:client_secret], Openlive.configuration.oauth_settings ) ) end |
#requisition_token ⇒ OAuth2::AccessToken
Fetch a new token from the OAuth server
42 43 44 |
# File 'lib/openlive/oauth.rb', line 42 def requisition_token self.current_token = client.client_credentials.get_token(scope: Openlive.configuration.oauth_settings[:scope]) end |
#token ⇒ OAuth2::AccessToken
Return an existing unexpired token for this OAuth instance or requisition a new one from the server.
30 31 32 33 34 35 36 |
# File 'lib/openlive/oauth.rb', line 30 def token if current_token.nil? || current_token.expired? requisition_token else current_token end end |