Class: Faraday::Request::OAuth2
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Request::OAuth2
- Defined in:
- lib/faraday/request/oauth2.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *args) ⇒ OAuth2
constructor
A new instance of OAuth2.
Constructor Details
#initialize(app, *args) ⇒ OAuth2
Returns a new instance of OAuth2.
19 20 21 22 |
# File 'lib/faraday/request/oauth2.rb', line 19 def initialize(app, *args) @app = app @token = args.shift end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/faraday/request/oauth2.rb', line 7 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 |