Class: Fizzy::BearerAuth

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(token_provider) ⇒ BearerAuth

Returns a new instance of BearerAuth.

Parameters:



27
28
29
# File 'lib/fizzy/auth_strategy.rb', line 27

def initialize(token_provider)
  @token_provider = token_provider
end

Instance Attribute Details

#token_providerTokenProvider (readonly)

Returns the underlying token provider.

Returns:



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