Class: Request::OAuth2
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Request::OAuth2
- Defined in:
- lib/faraday/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.
17 18 19 20 |
# File 'lib/faraday/oauth2.rb', line 17 def initialize(app, *args) @app = app @token = args.shift end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/faraday/oauth2.rb', line 9 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 |