Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OAuth 1.0a (requires oauth gem 0.3.5)

  • Loading branch information...
commit d7a6798e9a2b2a59e2de9ecf24bd295dab929d5f 1 parent b64af96
Wynn Netherland authored
View
8 app/controllers/sessions_controller.rb
@@ -3,7 +3,8 @@ class SessionsController < ApplicationController
def new
if TwitterAuth.oauth?
- @request_token = TwitterAuth.consumer.get_request_token
+ oauth_callback = request.protocol + request.host_with_port + '/oauth_callback'
+ @request_token = TwitterAuth.consumer.get_request_token({:oauth_callback=>oauth_callback})
session[:request_token] = @request_token.token
session[:request_token_secret] = @request_token.secret
@@ -36,7 +37,8 @@ def oauth_callback
@request_token = OAuth::RequestToken.new(TwitterAuth.consumer, session[:request_token], session[:request_token_secret])
- @access_token = @request_token.get_access_token
+ oauth_verifier = params["oauth_verifier"]
+ @access_token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)
# The request token has been invalidated
# so we nullify it in the session.
@@ -50,7 +52,7 @@ def oauth_callback
cookies[:remember_token] = @user.remember_me
authentication_succeeded
- rescue Net::HTTPServerException, Net::HTTPFatalError, TwitterAuth::Dispatcher::Error => e
+ rescue Net::HTTPServerException => e
case e.message
when '401 "Unauthorized"'
authentication_failed('This authentication request is no longer valid. Please try again.') and return
View
2  lib/twitter_auth/controller_extensions.rb
@@ -16,7 +16,7 @@ def authentication_failed(message, destination='/')
def authentication_succeeded(message = 'You have logged in successfully.', destination = '/')
flash[:notice] = message
- redirect_to destination
+ redirect_back_or_default destination
end
def current_user
Please sign in to comment.
Something went wrong with that request. Please try again.