简体   繁体   English

django社交认证从Google oauth2获得错误的access_token

[英]django social auth get wrong access_token from google oauth2

I am integrating google oauth2 to my website using django social auth. 我正在使用django social auth将google oauth2集成到我的网站。 The problem is that with django social auth , I get an access_token like 问题是,使用django social auth,我得到一个access_token像

ya29.2QCqpS-uKGXMNOP8yZnN6Z-F5LfVnyd7jwa8TaLP43nTEp2NUPB_p7Hi ya29.2QCqpS-uKGXMNOP8yZnN6Z-F5LfVnyd7jwa8TaLP43nTEp2NUPB_p7Hi

While with the code sample from google code the access token is like : 当使用来自Google代码的代码示例时,访问令牌类似于:

ya29.2QCVXKc7XSNR3QxqRVAi0Z8Uz6mvolDGpezbZ9_r_oq7CXt01WvE9oUb90HXaynOLE4J8PjA5pzYDB ya29.2QCVXKc7XSNR3QxqRVAi0Z8Uz6mvolDGpezbZ9_r_oq7CXt01WvE9oUb90HXaynOLE4J8PjA5pzYDB

The first one does not work while the second one works fine 第一个无效,而第二个正常

does anyone have any idea on this ? 有人对此有任何想法吗?

all right. 好吧。 it turns out to be a problem of scope . 事实证明这是范围问题。 the sample code set a default scope to mail.google.com while social-auth only have a default scope to read user information. 示例代码将默认范围设置为mail.google.com,而social-auth仅具有默认范围来读取用户信息。

the difference in length of token must be related to the scope 令牌长度的差异必须与范围有关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM