Sha256: a34627f583af722f1c6586b79ee787ac3a5ddb446fa06cc69c16753fceb133f1
Contents?: true
Size: 729 Bytes
Versions: 3
Compression:
Stored size: 729 Bytes
Contents
module LinkedIn module FaradayMiddleware class CredentialsRequest < Faraday::Middleware PARAM_NAME = 'oauth2_access_token'.freeze extend Forwardable def_delegators :'Faraday::Utils', :parse_query, :build_query def initialize(app, credentials) super app @credentials = credentials end 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 private def query_params(url) return {} if url.query.blank? parse_query url.query end end end end
Version data entries
3 entries across 3 versions & 1 rubygems