Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google+ Sign-in problem #285

Closed
kamikaze opened this issue May 22, 2014 · 29 comments
Closed

Google+ Sign-in problem #285

kamikaze opened this issue May 22, 2014 · 29 comments

Comments

@kamikaze
Copy link

When trying to login, I'm getting this from google:

  1. That’s an error.

Error: invalid_scope

Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/userinfo.email], invalid=[plus.login]}

@omab
Copy link
Owner

omab commented May 22, 2014

Google OAuth2?

@kamikaze
Copy link
Author

social.backends.google.GooglePlusAuth

@AndrewJHart
Copy link

I typically don't post to issues but I've been working for several hours to no avail with a consistent response of invalid scope using the GooglePlusAuth and always 403 Forbidden on GoogleOAuth2.

I will post the stack trace if needed -

Thx

@AndrewJHart
Copy link

@kamikaze @omab If you remove the plus.login scope it will authenticate the app for the GooglePlusAuth, however I still end with a 403 Client Error: Forbidden response.

I must be missing something simple at this point -- please help?

@bettsmatt
Copy link

I am having the same issues. I have updated and deployed the fix from e352518 but requests continue to come back as 403.

Any progress on fixing this issue?

@AndrewJHart
Copy link

Just a note - tests on this are failing for me as well.

However, from what I can gather (ergo my reason for being hesitant to post), if the HTTP response is a 403 then isn't that indicative of some kind of issue/requirement e.g. permissions on google's end??

But I have followed advice from many various sources in an attempt to remedy the issue by adjusting permissions, etc.. on the google app acct and I still get a 403 Forbidden every time.

So I'm wondering if this issue has something to do with python-social-auth.

Thanks - any help or direction would be awesome.

@bettsmatt
Copy link

I took a closer look at the error I was having.
Turns out it was a problem with the API's we had enabled in the Google Developer Console.

Google Oauth2 is authenticating correctly and returning a valid access token.
But when the access token is used to get the email address from Google + it is marked as unauthorised. As Google + was not an enabled API in the Google developer console.

I found this by calling
https://www.googleapis.com/plus/v1/people/me?access_token=<ACCESS_TOKEN> with the access token obtained through python social auth. As I would get the following error "Access Not Configured. Please use Google Developers Console to activate the API for your project."

Once I turned on the Google + API in the developer console everything worked perfectly.

@AndrewJHart, @kamikaze hope this helps.

@kamikaze
Copy link
Author

I've always had G+ API enabled, actually everything worked until pyton-social-auth changed to new API (e352518)

but is there a fact that new API is supported by Google right now?

@Uznick
Copy link

Uznick commented May 26, 2014

Same problem here, it just does not work :(

@omab
Copy link
Owner

omab commented May 26, 2014

Google is deprecating the old scopes, dropping support starting from Sept 1, 2014, check the table at https://developers.google.com/+/api/auth-migration#timetable.

I wasn't aware that the new scopes requires the Google+ API to be enabled in the dashboard, I've already had it enabled.

I've added documents regarding the scopes deprecation and workaround for those looking to keep the old scopes at http://psa.matiasaguirre.net/docs/backends/google.html#scopes-deprecation

@Uznick
Copy link

Uznick commented May 27, 2014

I have enabled the Google+ API in the dashboard.

And I have the following settings in my Django settings.py:

GOOGLE_OAUTH2_CLIENT_ID = 'xxx.apps.googleusercontent.com'
GOOGLE_OAUTH2_CLIENT_SECRET = 'yyyyyy'
I have 'social.backends.google.GooglePlusAuth' in my AUTHENTICATION_BACKENDS
And I use {% url 'social:begin' 'google-plus' %} to login via Google+.

And when I follow the link I get:

Environment:


Request Method: GET
Request URL: http://localhost:8000/login/google-plus/?next=/registration/%3Ffrom%3Dgoogle

Django Version: 1.6.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'velobike.apps.main',
 'velobike.apps.content',
 'velobike.apps.core',
 'velobike.apps.configuration',
 'suit',
 'django.contrib.admin',
 'south',
 'social.apps.django_app.default',
 'linaro_django_pagination',
 'django_summernote',
 'solo',
 'modeltranslation',
 'mathfilters')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'linaro_django_pagination.middleware.PaginationMiddleware',
 'velobike.apps.core.middleware.VeloAuthMiddleware')


Traceback:
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  45.             return func(request, backend, *args, **kwargs)
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/social/apps/django_app/views.py" in auth
  12.     return do_auth(request.social_strategy, redirect_name=REDIRECT_FIELD_NAME)
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/social/actions.py" in do_auth
  25.     return strategy.start()
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/social/strategies/base.py" in start
  66.             return self.redirect(self.backend.auth_url())
File "/Users/uznick/.virtualenvs/velobike-web/lib/python2.7/site-packages/social/backends/oauth.py" in auth_url
  291.         return self.AUTHORIZATION_URL + '?' + params

Exception Type: TypeError at /login/google-plus/
Exception Value: unsupported operand type(s) for +: 'NoneType' and 'str'

@kamikaze
Copy link
Author

but I have Google+ API enabled already...

@pryankster
Copy link

@Uznick : I'm seeing the same issue. AUTHORIZATION_URL isn't being set in the GooglePlusAuth class -- none of its parent classes define it.

class BaseGoogleAuth(object): # backends/google.py[12]
class BaseGoogleOAuth2API(BaseGoogleAuth): # backends/google.py[42]
class GooglePlusAuth(BaseGoogleOAuth2API, BaseOAuth2):  # backends/google.py[74]

Maybe it should inherit BaseGoogleOAuth2 (which inherits BaseGoogleOAuth2API, or it should define the AUTHORIZATION_URL (and other) constants directly in the class? I haven't used the G+ API enough to know what the proper patch is.

@omab
Copy link
Owner

omab commented Jun 7, 2014

I've released v0.1.26 which fixes the scopes issue by restoring the previous values but the new values are used by default, in order to re-enable the old (deprecated) scopes you need set any of this settings:

SOCIAL_AUTH_GOOGLE_OAUTH2_USE_DEPRECATED_API = True
SOCIAL_AUTH_GOOGLE_PLUS_USE_DEPRECATED_API = True

Also added support for Goggle+ Sign In server-side flow.

@omab omab closed this as completed Jun 7, 2014
@kamikaze
Copy link
Author

kamikaze commented Jun 9, 2014

Thanks

@shoooe
Copy link

shoooe commented Aug 18, 2014

I'm using v0.1.26 and I still get 403 (even with Google+ API enabled). In fact if I take the access_token from the debug backtrace and go to:

https://www.googleapis.com/plus/v1/people/me?access_token=<access_token>

I'm perfectly able to see the correct response.

It is to say that I'm testing without HTTPS enabled on my end; might that be the cause of this problem?

@jrasanen
Copy link

Hmm, what is the non-deprecated API then?

@shoooe
Copy link

shoooe commented Sep 6, 2014

My problem was that Google+ API was Off in the Developer Console at Google.

@naoko
Copy link

naoko commented Oct 2, 2014

Thank you, After enable Google+ API i was able to solve this issue as well

@avibrazil
Copy link
Contributor

Me too... I had to enable Google+ API even if not needed by my app.

@vahedq
Copy link

vahedq commented Aug 22, 2015

Are you guys still able to use this fine? I have it set up, and Google+ API is enabled, but am getting this error:

Traceback (most recent call last):
File "/storage/client/repo1/server/eagle/views.py", line 56, in register_by_access_token
user = backend.do_auth(access_token)
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py", line 383, in do_auth
data = self.user_data(access_token, _args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/google.py", line 74, in user_data
'alt': 'json'
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py", line 229, in get_json
return self.request(url, _args, *_kwargs).json()
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py", line 225, in request
response.raise_for_status()
File "/usr/lib/python2.7/dist-packages/requests/models.py", line 773, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 403 Client Error: Forbidden

@divestrato
Copy link

I have the same problem as @vahedq as well. Any pointers will be much appreciated!

@omab
Copy link
Owner

omab commented Sep 1, 2015

Yesterday I've updated the Google+ Sign-In docs and fixed some issues in the backend, take a look to the docs here http://psa.matiasaguirre.net/docs/backends/google.html?_=123#google-sign-in it might help.

@morninj
Copy link

morninj commented Oct 29, 2015

I had the same issue. I solved it by enabling the Google+ API from console.developers.google.com.

@sureshvv
Copy link

sureshvv commented Dec 7, 2015

+1 to bettsmatt & morninj

@chandrunitk
Copy link

bettsmatt's solution did it for me!

@rajeeshrp
Copy link

I still struggling with the same problem as @vahedq Project created, Google+ API enabled. My UI (angularjs) is able to let user login by google and pass the access_token. When psa's backend.do_auth is invoked with token, 403 is raised. Testing is done localhost and an AWS client.

@naveen319
Copy link

Hi I am struggling with this issue,

TypeError at /social-auth/complete/google-oauth2/
unsupported operand type(s) for +: 'NoneType' and 'int'

I am getting this error even for Twitter and Facebook. Can any one please help me on this,

error

@lucasvazq
Copy link

For all those people that have the same issue, one alternative to solve it is to update the package. I have the problem in v1 and enabling Google+ doesn't solve it, but upgrading to v4 does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests