Google Integration Using Devise and Omniauth In Rails App.

GOOGLE INTEGRATION USING DEVISE AND OMNIAUTH IN RAILS APP.

Ruby on Rails

ruby-on-rails-logowwAdd118003-matte-blue-and-white-square-icon-social-media-logos-google-g-logo

In this blog i’ll show how to integrate Google authentication using devise.To install devise you can refer to my blog here.

Step:1
Add the gems in your gem file

gem ‘devise’gem 'omniauth'gem 'omniauth-google-oauth2' 

Run the “bundle install” command to install the gem.

Step:2
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.

Step:3
Go the user model “user.rb” and add the following line

devise : omniauthable

Step:4
First of all you need to create an app in google to get “Client key” and “Client Secret key”

https://code.google.com/apis/console/

Create an app and get the Client id and secret key.

Step:5
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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s