Class: Brine::ClientBuilding::OAuth2Params
- Inherits:
-
Object
- Object
- Brine::ClientBuilding::OAuth2Params
- Defined in:
- lib/brine/client_building.rb
Overview
Define OAuth2 middleware configuration.
This is essentially a thin wrapper around ‘github.com/oauth-xx/oauth2` to provide a mini-DSL and to facilitate the middleware configuration.
Instance Attribute Summary collapse
-
#token ⇒ Object
Store the token which has been retrieved from the authorization server.
-
#token_type ⇒ Object
Specify the type of OAuth2 token which will be retrieved.
Instance Method Summary collapse
-
#fetch_from(id, secret, opts) ⇒ Object
Fetch an OAuth2 token based on configuration and store as ‘token`.
-
#initialize ⇒ OAuth2Params
constructor
Instantiate a new object with default attributes.
Constructor Details
#initialize ⇒ OAuth2Params
Instantiate a new object with default attributes.
37 38 39 |
# File 'lib/brine/client_building.rb', line 37 def initialize @token_type = 'bearer' end |
Instance Attribute Details
#token ⇒ Object
Store the token which has been retrieved from the authorization server.
25 26 27 |
# File 'lib/brine/client_building.rb', line 25 def token @token end |
#token_type ⇒ Object
Specify the type of OAuth2 token which will be retrieved.
Currently only ‘bearer` is supported.
32 33 34 |
# File 'lib/brine/client_building.rb', line 32 def token_type @token_type end |
Instance Method Details
#fetch_from(id, secret, opts) ⇒ Object
Fetch an OAuth2 token based on configuration and store as ‘token`.
The parameters are forwarded to OAuth2::Client.new which is used to retrieve the token.
57 58 59 60 |
# File 'lib/brine/client_building.rb', line 57 def fetch_from(id, secret, opts) @token = OAuth2::Client.new(id, secret, opts) .client_credentials.get_token.token end |