Sha256: 56761789860395d985be911dc6b1ba8feee26b276211ebe871ffdbabf8696113

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

require 'faraday'

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

2 entries across 2 versions & 1 rubygems

Version Path
faraday_middleware-0.3.2 lib/faraday/oauth2.rb
faraday_middleware-0.3.1 lib/faraday/oauth2.rb