Permalink
Browse files

Embed oauth_callback into request_token so Twitter redirects back pro…

…perly
  • Loading branch information...
1 parent 7dafa74 commit ac7d3de9324695d3046af4f493fda8cf4b820837 @jasonm jasonm committed Mar 14, 2010
View
@@ -0,0 +1,2 @@
+Clean it up
+Don't send an email
@@ -1,13 +1,10 @@
class ClearanceTwitter::TwitterUsersController < ApplicationController
def new
- oauth_callback = request.protocol + request.host_with_port + '/oauth_callback'
- @request_token = ClearanceTwitter.consumer.get_request_token # what is this needed for? ...get_request_token({:oauth_callback=>oauth_callback})
+ oauth_callback = request.protocol + request.host_with_port + ClearanceTwitter.oauth_callback
+ @request_token = ClearanceTwitter.consumer.get_request_token({:oauth_callback=>oauth_callback})
session[:request_token] = @request_token.token
session[:request_token_secret] = @request_token.secret
-
- url = @request_token.authorize_url
- url << "&oauth_callback=#{CGI.escape(ClearanceTwitter.oauth_callback)}"
- redirect_to url
+ redirect_to @request_token.authorize_url
end
def oauth_callback
@@ -8,6 +8,7 @@ development:
# Learn more at: http://apiwiki.twitter.com/Sign-in-with-Twitter
authorize_path: "/oauth/authenticate"
+ oauth_callback: "http://localhost:3000/twitter_users/oauth_callback"
# api_timeout: 10
# remember_for: 14 # days
test:
@@ -18,6 +19,7 @@ test:
authorize_path: "/oauth/authenticate"
# api_timeout: 10
# remember_for: 14 # days
+ oauth_callback: "http://example.com/twitter_users/oauth_callback"
cucumber:
strategy: oauth
oauth_consumer_key: testkey
@@ -26,3 +28,4 @@ cucumber:
authorize_path: "/oauth/authenticate"
# api_timeout: 10
# remember_for: 14 # days
+ oauth_callback: "http://example.com/twitter_users/oauth_callback"
@@ -18,10 +18,7 @@
Then 'I should be directed to sign in with Twitter' do
request_token = ClearanceTwitter.consumer.get_request_token
- authorize_url = request_token.authorize_url
- authorize_url << "&oauth_callback=#{CGI.escape(ClearanceTwitter.oauth_callback)}"
-
- assert_redirected_to authorize_url
+ assert_redirected_to request_token.authorize_url
end
Then /^there should be (\d+) users? in the system$/ do |count|
@@ -57,7 +57,7 @@ def self.path_prefix
# end
def self.oauth_callback
- config['oauth_callback'] || '/twitter_users/oauth_callback'
+ config['oauth_callback']
end
end

0 comments on commit ac7d3de

Please sign in to comment.