invalid_grant 试图从谷歌获取 oAuth 令牌 [英] invalid_grant trying to get oAuth token from google

查看:27
本文介绍了invalid_grant 试图从谷歌获取 oAuth 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试从 Google 获取 oAuth 令牌以连接到他们的联系人 API 时,我不断收到 invalid_grant 错误.所有信息都是正确的,我已经检查过这件事,这让我很困惑.

I keep getting an invalid_grant error on trying to get an oAuth token from Google to connect to their contacts api. All the information is correct and I have tripple checked this so kind of stumped.

有谁知道是什么导致了这个问题?我尝试为它设置不同的客户端 ID,但得到相同的结果,我尝试连接许多不同的方法,包括尝试强制身份验证,但结果仍然相同.

Does anyone know what may be causing this issue? I have tried setting up a different client id for it but I get the same result, I have tried connecting many different ways including trying the force authentication, but still the same result.

推荐答案

当我在将用户发送到 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.)

这篇关于invalid_grant 试图从谷歌获取 oAuth 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆