Class: Fizzy::BearerAuth
- Inherits:
-
Object
- Object
- Fizzy::BearerAuth
- Includes:
- AuthStrategy
- Defined in:
- lib/fizzy/auth_strategy.rb
Overview
Bearer token authentication strategy (default). Sets the Authorization header with “Bearer token”.
Instance Attribute Summary collapse
-
#token_provider ⇒ TokenProvider
readonly
The underlying token provider.
Instance Method Summary collapse
- #authenticate(headers) ⇒ Object
-
#initialize(token_provider) ⇒ BearerAuth
constructor
A new instance of BearerAuth.
Constructor Details
#initialize(token_provider) ⇒ BearerAuth
Returns a new instance of BearerAuth.
27 28 29 |
# File 'lib/fizzy/auth_strategy.rb', line 27 def initialize(token_provider) @token_provider = token_provider end |
Instance Attribute Details
#token_provider ⇒ TokenProvider (readonly)
Returns the underlying token provider.
32 33 34 |
# File 'lib/fizzy/auth_strategy.rb', line 32 def token_provider @token_provider end |
Instance Method Details
#authenticate(headers) ⇒ Object
34 35 36 |
# File 'lib/fizzy/auth_strategy.rb', line 34 def authenticate(headers) headers["Authorization"] = "Bearer #{@token_provider.access_token}" end |