Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google oauth scope changed during authentication, but scope is same

Tags:

google-oauth

I created an app that requires google scopes, and it was working until now. I get this error:

Error
ERROR:Scope has changed from "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://mail.google.com" to "https://mail.google.com/ https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile".

BEFORE:

"https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile 
https://mail.google.com"

AFTER:

"https://mail.google.com/ 
https://www.googleapis.com/auth/userinfo.email 
https://www.googleapis.com/auth/userinfo.profile"

As far as I can see the scope did NOT change. There are 3 scopes before and after, but only the order has changed.

The python code for this is here:

try:
    credentials = oauth.fetch_token('https://accounts.google.com/o/oauth2/token',
    authorization_response = full_authorization_response_url,
    client_secret=client_secret)
except Exception as e:
    import traceback
    print(traceback.format_exc())
    credentials = 'ERROR:'+str(e)
if type(credentials) in (str,unicode):
    return "Error<br>"+credentials

it's that last line that seems to be relevant. So google is saying the scope changed, but I can't see why, or how to fix it, since it hasn't changed.

like image 897
Marc Maxmeister Avatar asked Nov 06 '18 16:11

Marc Maxmeister


1 Answers

I found that relaxing the token scope on the server solved this problem. It apparently expects the same scopes in the same order, unless you add this line:

os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = '1'
like image 136
Marc Maxmeister Avatar answered Sep 25 '22 23:09

Marc Maxmeister