Devise / OmniAuth / Twitter - OAuth :: Unauthorized (401)

I am trying to configure Twitter login using Devise / OmniAuth, following the latest RailsCast for this. I registered the Twitter app developer using the URL-address of a callback: myiphere:port/users/auth/twitter.

I followed everything up to T on RailsCast, but every time I click the link Sign In With Twitter, I get it right away OAuth::Unauthorized 401 Unauthorized on the myiphere:port/users/auth/twitter page.

I think I correctly defined the key using export TWITTER_CONSUMER_KEY=MYKEYINSERTEDHERE export TWITTWR_CONSUMER_SECRET=MYSECRETINSERTEDHERE rails server. I tried most of the solutions that I can find on the Internet, but all of this failed. Almost all answers relate to returning to your site after logging in, I can’t get to any Twitter screen, just error 401 on the page /users/auth/twitter.

+5
source share
5

; API, URL- Twitter https://dev.twitter.com/apps/ "".

, , URL- , ; , Twitter - .

, omniauth-twitter, .

+17

, ENV DEVISE.RB:

config.omniauth :twitter, "APP_ID", "APP_SECRET"

callback, DEV Twitter:

http://www.mysite.com/users/auth/twitter/callback

routes.rb

devise_for :users, controllers: {omniauth_callbacks: "omniauth_callbacks"}

-:

<%= link_to "Log in with Twitter", user_omniauth_authorize_path(:twitter) %>
+2

, , TWITTER_CONSUMER_KEY TWITTER_CONSUMER_SECRET, , . ENV[] , , .

+1

You need to add the figaro gem to use environment variables, as in the video. The link will guide you through the setup.

http://railsapps.imtqy.com/rails-environment-variables.html

0
source

For me, the problem was that "Allow using this application to log in using Twitter" was not checked (on the "Application Settings" tab)

0
source

All Articles