Class: Square::OAuth2

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

Overview

Utility class for OAuth 2 authorization and token management.

Instance Method Summary collapse

Constructor Details

#initialize(bearer_auth_credentials) ⇒ OAuth2

Initialization constructor.



12
13
14
15
16
17
18
19
# File 'lib/square/http/auth/o_auth2.rb', line 12

def initialize(bearer_auth_credentials)
  auth_params = {}
  @_access_token = bearer_auth_credentials.access_token unless
    bearer_auth_credentials.nil? || bearer_auth_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.



7
8
9
# File 'lib/square/http/auth/o_auth2.rb', line 7

def error_message
  'BearerAuth: access_token is undefined.'
end