I'm trying to set up a Twitter login using Devise/OmniAuth, following the latest RailsCast for this. I've registered the Twitter developer app, using the callback url of: myiphere:port/users/auth/twitter
.
I've followed everything to the T on the RailsCast, but each time I click the Sign In With Twitter
link, I immediately get OAuth::Unauthorized 401 Unauthorized on the myiphere:port/users/auth/twitter page
.
I think I've defined the key correctly using export TWITTER_CONSUMER_KEY=MYKEYINSERTEDHERE export TWITTWR_CONSUMER_SECRET=MYSECRETINSERTEDHERE rails server
. I've tried most every solution I can find on the internet, all to no avail. Almost all of the answers are for returning back to their site once logged in, I can't get to any kind of Twitter screen, just the 401 error on the /users/auth/twitter
page.
I had this same issue; in my case, I had the API keys set up correctly, but had not set a callback URL in the Twitter setup at https://dev.twitter.com/apps/, under the "Settings" tab.
Oddly, it doesn't appear that the callback URL needs to point anywhere useful; Twitter apparently just uses its existence as a signal of some sort.
The debugging information provided by omniauth-twitter leaves something to be desired.
I got it to work by removing the brackets and ENV from the initializer DEVISE.RB:
config.omniauth :twitter, "APP_ID", "APP_SECRET"
my callback specified in DEV Twitter settings:
http://www.mysite.com/users/auth/twitter/callback
In routes.rb
devise_for :users, controllers: {omniauth_callbacks: "omniauth_callbacks"}
My LogIn link:
<%= link_to "Log in with Twitter", user_omniauth_authorize_path(:twitter) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With