Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Most Google Oauth2 API not working - Google Email scope fix #452

Merged
merged 2 commits into from

2 participants

@soorajb

Google Oauth2 stratergy is not working most of the Google APIs, unless the email scope is manually provided.(https://www.googleapis.com/auth/userinfo.email) in the initializer.

In line23, the scope for accessing user email will be ovverrided if a scope is already provided in the initializer. So, in the callback phase when oauth tries to retrieve user email, there is an invalid credentials exception (as there is no scope for accessing user email)

So, a fix to add this email scope by default.

@sferik sferik merged commit d5b1bb6 into intridea:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 2, 2011
  1. @soorajb

    Fix for google email scope.

    soorajb authored
  2. @soorajb
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 oa-oauth/lib/omniauth/strategies/google_oauth2.rb
View
4 oa-oauth/lib/omniauth/strategies/google_oauth2.rb
@@ -20,7 +20,9 @@ def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
end
def request_phase
- options[:scope] ||= "https://www.googleapis.com/auth/userinfo.email"
+ google_email_scope = "www.googleapis.com/auth/userinfo.email"
+ options[:scope] ||= "https://#{google_email_scope}"
+ options[:scope] << "https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}]
redirect client.auth_code.authorize_url(
{:redirect_uri => callback_url, :response_type => "code"}.merge(options))
end
Something went wrong with that request. Please try again.