Sha256: 6f31e009244bac8a0b1f03a7aa37084e2c7bf8d64761ff47a2f93837f88adc70

Contents?: true

Size: 511 Bytes

Versions: 5

Compression:

Stored size: 511 Bytes

Contents

module Faraday
  class Request::OAuth2 < Faraday::Middleware
    begin
      require 'oauth2'
    rescue LoadError, NameError => error
      self.load_error = error
    end

    def call(env)
      params = env[:url].query_values || {}
      env[:url].query_values = params.merge('access_token' => @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.3.0 lib/faraday/oauth2.rb
faraday_middleware-0.2.3 lib/faraday/oauth2.rb
faraday_middleware-0.2.2 lib/faraday/oauth2.rb
faraday_middleware-0.2.1 lib/faraday/oauth2.rb
faraday_middleware-0.2.0 lib/faraday/oauth2.rb