Sha256: 4cb50f1dd70d2f07557d7328a5075c57f25f91d7d1d4872975782ca7e398cfab

Contents?: true

Size: 501 Bytes

Versions: 5

Compression:

Stored size: 501 Bytes

Contents

require 'faraday'

module Faraday
  class Request::OAuth2 < Faraday::Middleware
    dependency 'oauth2'

    def call(env)
      params = env[:url].query_values || {}

      env[:url].query_values = { 'access_token' => @token }.merge(params)

      token = env[:url].query_values['access_token']

      env[:request_headers].merge!('Authorization' => "Token token=\"#{token}\"")

      @app.call env
    end

    def initialize(app, *args)
      @app = app
      @token = args.shift
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
faraday_middleware-0.7.0 lib/faraday/request/oauth2.rb
faraday_middleware-0.7.0.rc1 lib/faraday/request/oauth2.rb
faraday_middleware-0.6.5 lib/faraday/request/oauth2.rb
faraday_middleware-0.6.3 lib/faraday/request/oauth2.rb
faraday_middleware-0.6.0 lib/faraday/request/oauth2.rb