Class: ContextIO::Request::ContextIOOAuth Private

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/context-io/request/oauth.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Faraday middleware for handling the OAuth header

API:

  • private

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ ContextIOOAuth

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the OAuth middleware

Options Hash (options):

  • :consumer_key (String)

    The OAuth consumer key

  • :consumer_secret (String)

    The OAuth consumer secret

  • :token (nil)

    The OAuth token, should be nil since Context.IO doesn't support three-legged authentication.

  • :token_secret (nil)

    The Oauth token secret, should be nil since Context.IO doesn't support three-legged authentication.

Parameters:

  • next Rack middleware of app to call.

  • The authentication options to use for OAuth authentication.

API:

  • private



38
39
40
# File 'lib/context-io/request/oauth.rb', line 38

def initialize(app, options)
  @app, @options = app, options
end

Instance Method Details

#call(env) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add the OAuth header

Parameters:

  • The Rack environment

Returns:

  • The Rack response

API:

  • private



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/context-io/request/oauth.rb', line 15

def call(env)
  params = env[:body] || {}
  signature_params = params
  params.each do |key, value|
    signature_params = {} if value.respond_to?(:content_type)
  end
  header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)
  env[:request_headers]['Authorization'] = header.to_s

  @app.call(env)
end