Class: Faraday::Panoptes::AccessTokenAuthentication

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/panoptes/access_token_authentication.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, url:, access_token:) ⇒ AccessTokenAuthentication

Returns a new instance of AccessTokenAuthentication.



11
12
13
14
# File 'lib/faraday/panoptes/access_token_authentication.rb', line 11

def initialize(app, url:, access_token:)
  super(app)
  @access_token = access_token
end

Instance Method Details

#access_tokenObject



25
26
27
# File 'lib/faraday/panoptes/access_token_authentication.rb', line 25

def access_token
  @access_token
end

#authorization_headerObject



21
22
23
# File 'lib/faraday/panoptes/access_token_authentication.rb', line 21

def authorization_header
  "Bearer #{access_token}"
end

#call(env) ⇒ Object



16
17
18
19
# File 'lib/faraday/panoptes/access_token_authentication.rb', line 16

def call(env)
  env[:request_headers]["Authorization"] = authorization_header
  @app.call(env)
end