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 8000469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:48:15+00:00 2026-06-04T15:48:15+00:00

I am building a Rails application with Omniauth for log in service.To authenticate Google

  • 0

I am building a Rails application with Omniauth for log in service.To authenticate Google I am using OmniAuth Google OAuth2 Strategy.

When user clicks ‘allow access’ button everything works fine.But when user clicks ‘no thanks’ button the below error is raised.

OmniAuth::Strategies::OAuth2::CallbackError

I have tried adding the below rescue code in application controller.

class ApplicationController < ActionController::Base
  rescue_from OmniAuth::Strategies::OAuth2::CallbackError, :with =>
    :omniauth_callback_error_handler

 protected

 def omniauth_callback_error_handler
  redirect_to init_sign_in_users_path
 end
end

But no luck. Any idea?

  • 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-04T15:48:17+00:00Added an answer on June 4, 2026 at 3:48 pm

    This happens because the authentication happens in a middleware so your controller is not involved in it. This is where the exception is raised and the called code is this

    I think you can handle this kind of error by defining a callback in OmniAuth initializer with this kind of code

    OmniAuth.config do |config|
      config.on_failure do
        # your handling code invoked in the context of a rack app
      end
    end
    

    Otherwise there is a commit of three months ago which introduce this behavior

    def redirect_to_failure
      message_key = env['omniauth.error.type']
      new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
      Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish
    end
    

    which states that on errors your user is redirected to /auth/failure with an error message, so you should be able to define a route for that path and handle it in your app. Keep in mind that this won’t happen in development mode so you need to try it in other envs. If this doesn’t happen in production try to upgrade your omniauth gem to version 1.1.0

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

Sidebar

Related Questions

I'm building a Rails application using Devise. Devise is all set up even omniauth.
I'm building a Rails application that validates user input against an external REST service.
I'm building a Rails application using MongoDB as the back-end and MongoMapper as the
I'm building a Flex 4 + Rails 2.3.5 application. First I was using XML
I am building a Rails application which allows a user to create an object
I'm building a Rails 3 application on CouchDB (using SimplyStored gem) and I'd like
I'm building Rails application and I want to have user registration/login functionality. I also
I am building an application using Ruby on Rails. I want to do something
I am building a rails application using devise for authentication - including :confirmable functionality.
I'm building a Rails 3 application that will have user-specific settings (looks, functionality, etc)

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.