DEV Community

Cover image for Google Login in Rails 7 with devise

Google Login in Rails 7 with devise

Ahmad Raza on June 20, 2023

Google login can provide a convenient and seamless authentication option for your users. In this comprehensive guide, we'll walk you through the st...
Collapse
 
rafaeldev profile image
Rafael Gomes

Thank you for your post!

I had a problem with the CSRF token, it's because I'm putting Google login button inside the old sign-in form.

omniauth: (google_oauth2) Authentication failure! ActionController::InvalidAuthenticityToken

I'm posting this to other guys 🫡

Collapse
 
kumarkalyan profile image
Kumar Kalyan

Nice article! easy to understand

Collapse
 
ahmadraza profile image
Ahmad Raza • Edited

Thanks for your kind words @kumarkalyan! 🚀

I'm really glad that you found this article helpful 🙂

Collapse
 
ahmadraza profile image
Ahmad Raza

Btw, I loved your weather app article. It was awesome!

Collapse
 
ahmadraza profile image
Ahmad Raza

Feel free to ask any doubt!

Collapse
 
gmcamposano profile image
gmcamposano

Hello! Is there a reason why you configured differently from the proposed controller methods and model method from the docs? Ex. users/omniauth_callbacks_controller.rb is different from the docs and also the from_google method which uses the "unless user ..."

Collapse
 
nick_mealey_e809e2ab09fef profile image
Nick Mealey

In routes.rb shouldn't it be devise_for :users?

Collapse
 
noctivityinc profile image
noctivityinc

This is amazing. How would you customize the sign up and sign in buttons for google?

Collapse
 
enoch_73a9dd4d1308ddfbed6 profile image
Enoch

thanks this was super helpful

Collapse
 
enoch_73a9dd4d1308ddfbed6 profile image
Enoch

still works with Rails 8 btw