Class: MultiAuthSample::OAuthBearerToken

Inherits:
CoreLibrary::HeaderAuth
  • Object
show all
Defined in:
lib/multi_auth_sample/http/auth/o_auth_bearer_token.rb

Overview

Utility class for OAuth 2 authorization and token management.

Instance Method Summary collapse

Constructor Details

#initialize(o_auth_bearer_token_credentials) ⇒ OAuthBearerToken

Initialization constructor.



16
17
18
19
20
21
22
23
# File 'lib/multi_auth_sample/http/auth/o_auth_bearer_token.rb', line 16

def initialize(o_auth_bearer_token_credentials)
  auth_params = {}
  @_access_token = o_auth_bearer_token_credentials.access_token unless
    o_auth_bearer_token_credentials.nil? || o_auth_bearer_token_credentials.access_token.nil?
  auth_params['Authorization'] = "Bearer #{@_access_token}" unless @_access_token.nil?

  super auth_params
end

Instance Method Details

#error_messageObject

Display error message on occurrence of authentication failure.



11
12
13
# File 'lib/multi_auth_sample/http/auth/o_auth_bearer_token.rb', line 11

def error_message
  'OAuthBearerToken: access_token is undefined.'
end