Class: Basecamp::BearerAuth

Inherits:
Object
  • Object
show all
Includes:
AuthStrategy
Defined in:
lib/basecamp/bearer_auth.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:



10
11
12
# File 'lib/basecamp/bearer_auth.rb', line 10

def initialize(token_provider)
  @token_provider = token_provider
end

Instance Attribute Details

#token_providerTokenProvider (readonly)

Returns the underlying token provider.

Returns:



15
16
17
# File 'lib/basecamp/bearer_auth.rb', line 15

def token_provider
  @token_provider
end

Instance Method Details

#authenticate(headers) ⇒ Object



17
18
19
# File 'lib/basecamp/bearer_auth.rb', line 17

def authenticate(headers)
  headers["Authorization"] = "Bearer #{@token_provider.access_token}"
end