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

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

问题描述

在试图从Google获取oAuth令牌以连接到他们的联系人api时,我一直收到 invalid_grant 错误。所有的信息是正确的,我有tripple检查这种如此难倒。



有谁知道可能会导致此问题?我曾试着为它设置一个不同的客户端ID,但我得到了相同的结果,我尝试过连接许多不同的方式,包括尝试强制认证,但仍然是相同的结果。

当我在将用户发送到OAuth时没有明确请求脱机访问时,我遇到了这个问题您想让此应用程序有权访问您的东西吗?



确保您在请求中指定access_type = offline。



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



(另外:我认为谷歌在2011年底加入了这个限制。如果你之前有旧的代币,你需要将你的用户发送到权限页面授权离线使用。)


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.

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.

解决方案

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.

Make sure you specify access_type=offline in your request.

Details here: https://developers.google.com/accounts/docs/OAuth2WebServer#offline

(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天全站免登陆