In this blog i’ll show how to integrate Google authentication using devise.To install devise you can refer to my blog here.
Add the gems in your gem file
gem ‘devise’gem 'omniauth'gem 'omniauth-google-oauth2'
Run the “bundle install” command to install the gem.
You need two more columns to store provider type and userid given from google
rails g migration AddProviderToUsers provider:string uid:string
Runt rake db:migrate to insert the columns in users table.
Go the user model “user.rb” and add the following line
devise : omniauthable
First of all you need to create an app in google to get “Client key” and “Client Secret key”
Create an app and get the Client id and secret key.
Now you need to declare the provider name and client id and key.Go to the file config/initializers/devise.rb and the following line
require 'omniauth-google-oauth2' config.omniauth :google_oauth2, "APP_ID", "APP_SECRET"…
View original post 195 more words