ruby-on-railsrubyruby-on-rails-3twitteromniauth

Twitter Omniauth error with Ruby on Rails


Hello I being trying to solve this issue, I am trying to integrate twitter omniauth without using the devise gem and is giving me the following error.

401 Unauthorized

My link in the sing in twitter is the following

<%= link_to "Sign in with Twitter", "/auth/twitter" %>

my confing/initializers/omniauth.rb is settled down as follow

Rails.application.config.middleware.use OmniAuth::Builder do

provider :twitter, ENV['xxxxx'], ENV['xxxxxxxxxxxx']

end

And for additional details I have already the app on the twitter setting turn on to allow sign in and have a callback url.

Thanks in for your help in advance.


Solution

  • You can find information on OAuth::Unauthorized 401 int twitter-omniauth gem

    If you said your callback url is set to localhost, I think it is the problem.

    You could use a url shortner and replace your callback url with the one that fits you.

    http://localhost:5000/ => http://localhost:5000/
    https://localhost:5000/ => https://localhost:5000/