Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support hitting the callback with oauth_token/oauth_token_secret

This is useful for situations such as Twitter's reverse auth for iOS.
  • Loading branch information...
commit 966db34e94703c99741838959f2ef7acc86afb51 1 parent 43008e4
@nevir nevir authored
View
5 lib/omniauth/strategies/oauth.rb
@@ -43,6 +43,11 @@ def request_phase
end
def callback_phase
+ if request['oauth_token'] && request['oauth_token_secret']
+ @access_token = ::OAuth::AccessToken.from_hash(consumer, Hashie::Mash.new(request.params))
+ return super
+ end
+
raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))
View
14 spec/omniauth/strategies/oauth_spec.rb
@@ -144,4 +144,18 @@ def session
last_request.env['omniauth.error.type'] = :session_expired
end
end
+
+ describe '/auth/{name}/callback with oauth_token and oauth_token_secret' do
+ before do
+ get '/auth/example.org/callback', {:oauth_token => 'yourtoken', :oauth_token_secret => 'soopersekret', :user_id => 123}, {'rack.session' => {}}
+ end
+
+ it 'should succeed' do
+ last_request.env['omniauth.auth']['credentials']['token'].should == 'yourtoken'
+ last_request.env['omniauth.auth']['credentials']['secret'].should == 'soopersekret'
+ last_request.env['omniauth.auth']['provider'].should == 'example.org'
+ last_request.env['omniauth.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
+ last_request.env['omniauth.auth']['extra']['access_token'].params['user_id'].should == '123'
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.