Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:23:15+00:00 2026-06-07T06:23:15+00:00

I am getting (twitter) Authentication failure! invalid_credentials: OAuth::Unauthorized, 401 Unauthorized error after successfully loin

  • 0

I am getting (twitter) Authentication failure! invalid_credentials: OAuth::Unauthorized, 401 Unauthorized error after successfully loin to twitter and page is redirected to sign in page

Here is the application configuration

routes.rb

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

devise.rb

config.omniauth :twitter, "KEY", "SECRET"

omniauth_callbacks_controller.rb

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController  
  def twitter
    auth = env["omniauth.auth"]
    Rails.logger.info("auth is **************** #{auth.to_yaml}")
    @user = user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.new
    if @user.persisted?
      flash[:notice] = I18n.t "devise.omniauth_callbacks.success"
      sign_in_and_redirect @user, :event => :authentication
    else
      session["devise.twitter_uid"] = auth["uid"]
      redirect_to new_user_registration_url
    end
  end
end

user.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :omniauthable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :provider, :uid
  # attr_accessible :title, :body
end

index.html.erb

<h3>Home</h3>

<%if user_signed_in? %>
  <div><%="Welcome #{current_user.email}"%></div>

<div><%=link_to "Logout", destroy_user_session_path, method: :delete%></div>

<%else%>
<div><%=link_to "Sign in twitter", user_omniauth_authorize_path(:twitter)%></div>
<%end%>

Console log

Started GET "/users/auth/twitter" for 127.0.0.1 at 2012-07-09 18:58:16 +0530
(twitter) Callback phase initiated.
(twitter) Callback phase initiated.
(twitter) Authentication failure! invalid_credentials: OAuth::Unauthorized, 401 Unauthorized

Started GET "/users/auth/twitter/callback?oauth_token=rLCEqgAWPtoIzce475sacKwoqU5baEdz0JnmldXE&oauth_verifier=xYPoz2LZGHQlmz4akoVGkarPtZTebCOmeWzPUqLcPA" for 127.0.0.1 at 2012-07-09 18:58:48 +0530
Processing by Users::OmniauthCallbacksController#failure as HTML
  Parameters: {"oauth_token"=>"rLCEqgAWPtoIzce475sacKwoqU5baEdz0JnmldXE", "oauth_verifier"=>"xYPoz2LZGHQlmz4akoVGkarPtZTebCOmeWzPUqLcPA"}
Redirected to http://localhost:3000/users/sign_in

Callback URL in dev.twitter.com
Earlier it was http://127.0.0.1:3000. From Devise, Omniauth and Twitter I changed it to http://127.0.0.1:3000/auth/twitter/callback but still getting error

Would anyone please help here to rectify the issue?

Thanks,
Amit Patel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:23:17+00:00Added an answer on June 7, 2026 at 6:23 am

    I found the issue. I have configured providers in both devise.rb and omniauth.rb. I simply removed omniauth.rb and it started working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting 401 when trying to login via Oauth with Twitter. I'm using
I am getting the following authentication error when trying to access Twitter using my
Hi I keep getting this error, I'm trying to get tweets from twitter via
I'm looking at implementing an app getting Twitter authorization via Oauth in Java. The
I am getting this error while using twitter bootstrap. I didn't get this error
Im trying to parse twitter trends but i keep getting a parser error at
I keep getting a Twitter 403 error for the search query being too many
I am using ShareKit. It's working properly with Twitter API, but getting error in
I am having a problem getting Twitter Bootstrap Carousel to begin looping automatically at
These are the memory leaks that I am getting: http://twitter.com/AWEHOFFICIAL/status/221182174811004929/photo/1/large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.