Class: AccessTokenAgent::Connector
- Inherits:
-
Object
- Object
- AccessTokenAgent::Connector
- Defined in:
- lib/access_token_agent/connector.rb
Constant Summary collapse
- FAKE_TOKEN =
'FakeAuthToken'.freeze
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Method Summary collapse
- #http_auth_header ⇒ Object
-
#initialize(host:, client_id:, client_secret:, fake_auth: false, access_token_path: '/oauth/token', scopes: nil) ⇒ Connector
constructor
A new instance of Connector.
- #token ⇒ Object
Constructor Details
#initialize(host:, client_id:, client_secret:, fake_auth: false, access_token_path: '/oauth/token', scopes: nil) ⇒ Connector
Returns a new instance of Connector.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/access_token_agent/connector.rb', line 11 def initialize(host:, client_id:, client_secret:, fake_auth: false, access_token_path: '/oauth/token', scopes: nil) @host = host @client_id = client_id @client_secret = client_secret @fake_auth = fake_auth @access_token_path = access_token_path @scopes = scopes end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
8 9 10 |
# File 'lib/access_token_agent/connector.rb', line 8 def instance @instance end |
Instance Method Details
#http_auth_header ⇒ Object
25 26 27 |
# File 'lib/access_token_agent/connector.rb', line 25 def http_auth_header { 'Authorization' => "Bearer #{token}" } end |
#token ⇒ Object
29 30 31 32 33 34 |
# File 'lib/access_token_agent/connector.rb', line 29 def token return FAKE_TOKEN if @fake_auth @known_token = fetch_token unless @known_token && @known_token.valid? @known_token.value end |