Skip to content

Commit

Permalink
Added a custom OAuth implementation to deal with Twitter's off specif…
Browse files Browse the repository at this point in the history
…ication implementation
  • Loading branch information
NateBarnes committed May 30, 2011
1 parent 55c8aef commit 5d2e7cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/faraday/request/oauth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'faraday'

module Faraday
class Request::OAuth < Faraday::Middleware
dependency 'simple_oauth'

def call(env)
params = env[:body] || {}
signature_params = params

params.map{ |k,v| signature_params = {} if v.respond_to?(:content_type) }

header = SimpleOAuth::Header.new(env[:method], env[:url], signature_params, @options)

env[:request_headers]['Authorization'] = header.to_s

@app.call(env)
end

def initialize(app, options)
@app, @options = app, options
end
end
end
1 change: 1 addition & 0 deletions lib/twitter/connection.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'faraday_middleware'
require 'faraday/request/multipart_with_file'
require 'faraday/request/gateway'
require 'faraday/request/oauth'
require 'faraday/response/raise_http_4xx'
require 'faraday/response/raise_http_5xx'

Expand Down

0 comments on commit 5d2e7cc

Please sign in to comment.