Class: LinkedIn::FaradayMiddleware::CredentialsRequest

Inherits:
Faraday::Middleware
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/linkedin/faraday_middleware/credentials_request.rb

Constant Summary collapse

PARAM_NAME =
'oauth2_access_token'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, credentials) ⇒ CredentialsRequest

Returns a new instance of CredentialsRequest.



9
10
11
12
# File 'lib/linkedin/faraday_middleware/credentials_request.rb', line 9

def initialize(app, credentials)
  super app
  @credentials = credentials
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/linkedin/faraday_middleware/credentials_request.rb', line 14

def call(env)
  params = query_params(env[:url]).reverse_merge PARAM_NAME => @credentials.access_token
  token = params[PARAM_NAME]

  env[:url].query = build_query params unless token.blank?

  @app.call env
end