Created: 2011-07-12 07:51
Updated: 2018-10-04 15:24


This is a simple implementation of the Google Hybrid strategy I made for Omniauth.


  • A domain name
  • Webspace attached to the domain name
  • Google Account

Notice: testing this will not work on http://localhost:3000, make sure you read the entire setup.



  1. First register your domain with Google using their Manage Domains page.
  2. Follow all the steps and make sure you verify the domain.
  3. In the 'Target URL path prefix:' field enter something like:
  4. Take note of the OAuth consumer key and secret.

Setting up your /etc/hosts file

As I mentioned before this will not work on http://localhost:3000, but you can get it to work locally through a simple trick. I'm just going to describe this for OSX/Linux, it works very similar on Windows.

  1. Open your /etc/hosts file:

    $ sudo vim /etc/hosts

  2. Add a line that points to for the domain you aim to use:

  3. Save and exit. You'll now be able to reach your local server through

  4. Don't forget to disable this when you're done ;).


  1. Clone the repo:

    $ git clone git://

  2. Run bundler:

    $ cd Google-Hybrid-Omniauth-implementation

    $ bundle install

Adding the consumer key and secret

  1. Open omniauth.rb in the initializers folder:

    $ vim config/initializers/omniauth.rb

  2. Change the :consumer_key and :consumer_secret to the information Google provider in the first step:

    :consumer_key => '[your key here]',

    :consumer_secret => '[your secret here]'

  3. Optionally change the scope by adding scope urls, found here:

    :scope => ["", ""],

Runing the application

  1. Open the application's Google Hybrid login url in the browser:

  2. Login using your Google credentials and notice it asks for GMail and Google Contacts permissions. Accept to see the rails app dump the token etc.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more