3

I'm using 'omniauth-google-oauth2' for sign in with google and follow all instruction here carefully

 https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview 

but i have error above.

my routes

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

devise.rb code

 config.omniauth :google_oauth2, "863625299460- 420n6c7lvad91dfvko60uamtvtr6huhf.apps.googleusercontent.com", "dcvA2aZRZi27KCQjWTYP30pw", { access_type: "offline", approval_prompt: "" } 

omniauth callback controller code

 def google_oauth2 #@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user) binding.pry #control not coming here end 

i have error below after callback. see screenshot

 https://github.com/zquestz/omniauth-google-oauth2/issues/52 

3 Answers 3

1

This looks like a route issue. If you do "rake routes | grep auth" what do you see?

Sign up to request clarification or add additional context in comments.

3 Comments

i have mtach route but it also not working match "/users/auth/google_login/callback" ,:to => "users/omniauth_callbacks#goole_oauth2"
i see using route grep command user_omniauth_authorize /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/google_oauth2/} user_omniauth_callback /users/auth/:action/callback(.:format) users/omniauth_callbacks#(?-mix:google_oauth2) user_omniauth_authorize /users/auth/:provider(.:format) devise/omniauth_callbacks#passthru {:provider=>/google_oauth2/} user_omniauth_callback /users/auth/:action/callback(.:format) devise/omniauth_callbacks#(?-mix:google_oauth2)
My error was i don't add this line. devise :omniauthable, :omniauth_providers => [:google_oauth2]
0

I had exactly the same problem you described. Make sure you require the omniauth-google-oauth2 gem in config/initializers/deviser.rb

# ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. require "omniauth-google-oauth2" config.omniauth :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"], { access_type: "offline", approval_prompt: "force" } 

I've added the entire portion of my devise.rb file to provide context.

Comments

0

It's very late but this answer might be useful for others

If you are using devise for authentication then devise by default generates routes in the route file devise_for :users and your omniouth_callback route should be above the default devise route so that it overwrites default devise route.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.