Class: UnivapayClientSdk::Oauth2

Inherits:
CoreLibrary::HeaderAuth
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/univapay_client_sdk/http/auth/oauth_2.rb

Overview

Utility class for OAuth 2 authorization and token management.

Instance Method Summary collapse

Constructor Details

#initialize(bearer_auth_credentials) ⇒ Oauth2

Initialization constructor.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/univapay_client_sdk/http/auth/oauth_2.rb', line 17

def initialize(bearer_auth_credentials)
  auth_params = {}
  unless bearer_auth_credentials.nil? ||
         bearer_auth_credentials.secret_key.nil? ||
         bearer_auth_credentials.jwt_token.nil?
    @_secret_key = bearer_auth_credentials.secret_key
    @_jwt_token = bearer_auth_credentials.jwt_token
  end
  auth_params[:Authorization] = "Bearer #{@_secret_key}.#{@_jwt_token}" unless @_secret_key.nil?

  super auth_params
end

Instance Method Details

#error_messageObject

Display error message on occurrence of authentication failure.



12
13
14
# File 'lib/univapay_client_sdk/http/auth/oauth_2.rb', line 12

def error_message
  'BearerAuth: secret_key/jwt_token is undefined.'
end