在使用oAuth和youtube进行身份验证时,为什么在第二次身份验证尝试时总是收到错误:invalid_grant? [英] When authenticating with oAuth and youtube, always get error : invalid_grant on 2nd auth attempt, why?
问题描述
截至昨天,我的应用程序能够通过oAuth 2.0第一次没有问题,但第二次(重新认证,同一个app +同一个用户)通过oauth 2.0进行身份验证,当我将accessToken我收到一个错误:
error:invalid_grant
我正在使用:
grant_type = authorization_code
就像他们所建议的那样。以前在2天前发生的事情是在重新验证网页时会说'你以前已经使用此应用程序进行过验证,你想再次授予它访问权限吗?'。我发现了一种方法来解决这个问题(至少对我们来说)。我发现了一种方法来解决这个问题(至少对我们来说)。重定向到accounts.google.com/o/oauth2/auth网址时,我们必须同时添加approval_prompt = force和access_type = offline。如果缺少一个,我们没有刷新标记。
这个url记录了所有的参数,但没有提及刷新标记: http://code.google.com/apis/accounts/docs/OAuth2WebServer.html
As of yesterday, my application is able to authenticate with google (youtube) via oAuth 2.0 the first time no problem but the 2nd time (re-authentication, same app + same user), when I exchange the requestToken for an accessToken I get an error:
error : invalid_grant
I'm using:
grant_type = authorization_code
like they suggest. What used to happen, before 2 days ago, was on re-authentication the web page would say 'you've already authenticated with this application before, would you like to grant it access again?'. What has changed or what could I be doing wrong?
I found a way to fix this (at least for us). When redirecting to the accounts.google.com/o/oauth2/auth url, we had to add both approval_prompt=force and access_type=offline. If one was missing, we got no refresh token.
This url documents all of the parameters, but says nothing about the refresh token: http://code.google.com/apis/accounts/docs/OAuth2WebServer.html
这篇关于在使用oAuth和youtube进行身份验证时,为什么在第二次身份验证尝试时总是收到错误:invalid_grant?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!