Sha256: 640d57834f7b7e010a59c47620c2fefb1df36fba5321b262acef783ce7f7b2a3

Contents?: true

Size: 736 Bytes

Versions: 28

Compression:

Stored size: 736 Bytes

Contents

# encoding: utf-8

require 'faraday'

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

      def call(env)
#         puts "ENV: #{env.inspect}"
#         puts "TOKEN : #{@token}"
#         puts "APP: #{@app}"

        # Extract parameters from the query
        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 # OAuth2
  end # Request
end # Github

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
github_api-0.5.1 lib/github_api/request/oauth2.rb
github_api-0.5.0 lib/github_api/request/oauth2.rb
github_api-0.5.0.rc1 lib/github_api/request/oauth2.rb
github_api-0.4.11 lib/github_api/request/oauth2.rb
github_api-0.4.10 lib/github_api/request/oauth2.rb
github_api-0.4.9 lib/github_api/request/oauth2.rb
github_api-0.4.8 lib/github_api/request/oauth2.rb
github_api-0.4.7 lib/github_api/request/oauth2.rb
github_api-0.4.6 lib/github_api/request/oauth2.rb
github_api-0.4.5 lib/github_api/request/oauth2.rb
github_api-0.4.4 lib/github_api/request/oauth2.rb
github_api-0.4.3 lib/github_api/request/oauth2.rb
github_api-0.4.2 lib/github_api/request/oauth2.rb
github_api-0.4.1 lib/github_api/request/oauth2.rb
github_api-0.4.0 lib/github_api/request/oauth2.rb
github_api-0.3.9 lib/github_api/request/oauth2.rb
github_api-0.3.8 lib/github_api/request/oauth2.rb
github_api-0.3.7 lib/github_api/request/oauth2.rb
github_api-0.3.6 lib/github_api/request/oauth2.rb
github_api-0.3.4 lib/github_api/request/oauth2.rb