I have figured this out in my case. I was using Pow as my web server and in my project folder had a folder called 'tmp'. You can tell POW to restart the server on every request by adding in a file called 'always_restart'. The fact that the server restarted on every request meant the the session token became invalid. By removing this file I got it to work.
Omniauth Twitter fails with session_expired error
-
24-09-2022 - |
Question
I have started building a small app and using Omniauth and the omniauth-twitter gems.
Everyhting is going fine until twitters hits the callback url and i get sent to the failure response with the error auth/failure?message=session_expired&strategy=twitter
.
Here is my code so far:
class Admin < Sinatra::Base
register Sinatra::Namespace
enable :sessions
use OmniAuth::Builder do
provider :twitter, 'Cient_ID', 'Client_secret'
end
namespace '/admin' do
get do
erb :index
end
get '/login/?' do
redirect '/auth/twitter'
end
end
get '/auth/twitter/callback' do
"You are now logged in"
end
end
When i go to /admin/login
I get redirect to twitter asking me to authorize the app and when I click "Allow" it redirects me back but I just get sent to the same failure screen over and over.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow