class Faraday::Request
Constants
- OAuth
Public: Uses the simple_oauth library to sign requests according the OAuth protocol.
The options for this middleware are forwarded to SimpleOAuth::Header: :consumer_key, :consumer_secret, :token, :token_secret. All these parameters are optional.
The signature is added to the “Authorization” HTTP request header. If the value for this header already exists, it is not overriden.
If no Content-Type header is specified, this middleware assumes that request body parameters should be included while signing the request. Otherwise, it only includes them if the Content-Type is “application/x-www-form-urlencoded”, as per OAuth 1.0.
For better performance while signing requests, this middleware should be positioned before UrlEncoded middleware on the stack, but after any other body-encoding middleware (such as EncodeJson).
- OAuth2
Public: A simple middleware that adds an access token to each request.
By default, the token is added as both “access_token” query parameter and the “Authorization” HTTP request header. It can alternatively be added exclusively as a bearer token “Authorization” header by specifying a “token_type” option of “bearer”. However, an explicit “access_token” parameter or “Authorization” header for the current request are not overriden.
Examples
# configure default token: OAuth2.new(app, 'abc123') # configure query parameter name: OAuth2.new(app, 'abc123', :param_name => 'my_oauth_token') # use bearer token authorization header only OAuth2.new(app, 'abc123', :token_type => 'bearer') # default token value is optional: OAuth2.new(app, :param_name => 'my_oauth_token')