Class: TrainPlugins::Rest::Bearer

Inherits:
AuthHandler show all
Defined in:
lib/train-rest/auth_handler/bearer.rb

Overview

Authentication via Bearer Authentication.

Instance Attribute Summary

Attributes inherited from AuthHandler

#connection, #options

Instance Method Summary collapse

Methods inherited from AuthHandler

#auth_headers, descendants, #initialize, #login, #logout, name, #renew_session, #renewal_needed?

Constructor Details

This class inherits a constructor from TrainPlugins::Rest::AuthHandler

Instance Method Details

#auth_parametersObject



15
16
17
18
19
20
21
# File 'lib/train-rest/auth_handler/bearer.rb', line 15

def auth_parameters
  {
    headers: {
      "Authorization" => format("Bearer %s", options[:token]),
    },
  }
end

#check_optionsObject

Raises:

  • (ArgumentError)


11
12
13
# File 'lib/train-rest/auth_handler/bearer.rb', line 11

def check_options
  raise ArgumentError.new("Need :token for Bearer authentication") unless options[:token]
end