Class: ResoTransport::Authentication::StaticTokenAuth

Inherits:
AuthStrategy
  • Object
show all
Defined in:
lib/reso_transport/authentication/static_token_auth.rb

Overview

A simple auth strategy that uses a static, non-expiring token.

Instance Attribute Summary collapse

Attributes inherited from AuthStrategy

#access

Instance Method Summary collapse

Methods inherited from AuthStrategy

#ensure_valid_access!, #reset

Constructor Details

#initialize(options) ⇒ StaticTokenAuth

Returns a new instance of StaticTokenAuth.



8
9
10
11
# File 'lib/reso_transport/authentication/static_token_auth.rb', line 8

def initialize(options)
  @access_token = options.fetch(:access_token)
  @token_type   = options.fetch(:token_type, "Bearer")
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/reso_transport/authentication/static_token_auth.rb', line 5

def access_token
  @access_token
end

#token_typeObject (readonly)

Returns the value of attribute token_type.



6
7
8
# File 'lib/reso_transport/authentication/static_token_auth.rb', line 6

def token_type
  @token_type
end

Instance Method Details

#authenticateAccess

Simply returns a static, never expiring access token

Returns:

  • (Access)

    The access token object



15
16
17
18
19
20
21
# File 'lib/reso_transport/authentication/static_token_auth.rb', line 15

def authenticate
  Access.new(
    access_token: access_token,
    token_type: token_type,
    expires_in: 1 << (1.size * 8 - 2) - 1 # Max int value
  )
end