且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

invalid_grant 试图从谷歌获取 oAuth 令牌

更新时间:2022-12-06 22:07:02

当我在将用户发送到 OAuth 时没有明确请求离线"访问权限时,我遇到了这个问题摸你的东西?"页面.

I ran into this problem when I didn't explicitly request "offline" access when sending the user to the OAuth "Do you want to give this app permission to touch your stuff?" page.

确保在请求中指定 access_type=offline.

Make sure you specify access_type=offline in your request.

此处的详细信息:https://developers.google.com/accounts/docs/OAuth2WebServer#offline

(另外:我认为 Google 在 2011 年末添加了此限制.如果您有之前的旧令牌,您需要将您的用户发送到权限页面以授权离线使用.)

(Also: I think Google added this restriction in late 2011. If you have old tokens from before then, you'll need to send your users to the permission page to authorize offline use.)