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.
- First register your domain with Google using their Manage Domains page.
- Follow all the steps and make sure you verify the domain.
- In the 'Target URL path prefix:' field enter something like: http://yourdomain.com/openid.
- Take note of the OAuth consumer key and secret.
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.
-
Open your /etc/hosts file:
$ sudo vim /etc/hosts
-
Add a line that points to 127.0.0.1 for the domain you aim to use:
127.0.0.1 yourdomain.com
-
Save and exit. You'll now be able to reach your local server through http://yourdomain.com:3000.
-
Don't forget to disable this when you're done ;).
-
Clone the repo:
$ git clone git://github.com/boyvanamstel/Google-Hybrid-Omniauth-implementation.git
-
Run bundler:
$ cd Google-Hybrid-Omniauth-implementation
$ bundle install
-
Open omniauth.rb in the initializers folder:
$ vim config/initializers/omniauth.rb
-
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]'
-
Optionally change the scope by adding scope urls, found here:
:scope => ["https://www.google.com/m8/feeds/", "https://mail.google.com/mail/feed/atom/"],
-
Open the application's Google Hybrid login url in the browser:
-
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.