Rails 6 Omniauth Google SignIn

Step 7: Now once it gives you the confirmation message that it was created go ahead and click on CREDENTIALS in the left menu.

<%= link_to "Log In With Google", '/auth/google_oauth2'%>
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, ENV['GOOGLE_CLIENT_KEY'], ENV['GOOGLE_CLIENT_SECRET']
get '/auth/:google_oauth2/callback' => 'sessions#google'
def google
@user = User.find_or_create_by(email: auth["info"]["email"]) do |user|
user.name= auth["info"]["first_name"]
user.password= SecureRandom.hex(8)
if @user && @user.id
session[:user_id] = @user.id
redirect_to custom_path
redirect_to another_path
private def auth




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building A Dynamic Inventory System for Ansible

Agility Without Story Points

OOPs concepts in Java

Azure Cosmos DB Part 3— Gremlin API

Game Design: Level Generation Using Binary Space Partitioning

How I Learned to Stop Worrying about Backend and love Postman

Introduction to Alteryx

Making your meteor node app fly part-2: Server response time optimization

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nerly Ton

Nerly Ton

More from Medium


My Summary of Refactoring Ui

How to fix Error: While trying to resolve module @apollo/client React Native

4MetaWorld First Weekly Chat Documentation