Skip to content
zquestz edited this page Feb 22, 2013 · 13 revisions

OmniAuth Google OAuth2 Strategy

Get your API key at https://code.google.com/apis/console/

FAQ's

Where is the omniauth path to start the oauth2 handshake?

Answer: auth/google_oauth2

What does a response from google look like during the handshake?

Answer: Example genericized hash returned from google:

{"provider"=>"google_oauth2",
 "uid"=>"999999999999999999999",
 "info"=>
  {"name"=>"First Last",
   "email"=>"First.Last@company_name.com",
   "first_name"=>"First",
   "last_name"=>"Last",
   "image"=>
    "https://lh3.googleusercontent.com/url/photo.jpg"},
 "credentials"=>
  {"token"=>"hash.of-stuff",
   "expires_at"=>1354920555,
   "expires"=>true},
 "extra"=>
  {"raw_info"=>
    {"id"=>"999999999999999999999",
     "email"=>"First.Last@company_name.com",
     "verified_email"=>true,
     "name"=>"First Last",
     "given_name"=>"First",
     "family_name"=>"Last",
     "link"=>"https://plus.google.com/999999999999999999999",
     "picture"=>
      "https://lh3.googleusercontent.com/-some/url/photo.jpg",
     "gender"=>"male",
     "birthday"=>"0000-06-25",
     "locale"=>"en",
     "hd"=>"company_name.com"}
  }
}

Tips on the scope parameter

  • You don't need the https://www.googleapis.com/auth/ prefix.
  • You provide a comma separated list, without spaces.
  • You need to give userinfo.email to get the email.
Clone this wiki locally