佚名通过本文主要向大家介绍了invalid grant,invalid grant type,error invalid grant,grant,grant是什么意思等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: IOS使用google+登陆提示 invalid_grant
描述:
解决方案1:
描述:
公司的app允许使用google账号登陆。
为使服务器能使用已登录用户的google账号读取用户信息,使用了 https://developers.google.com/+/web/signin/server-side-flow 文中所说的one-time-code flow 方案。
参考官方文档 https://developers.google.com/+/mobile/ios/sign-in
向服务器发送serverCode (就是文中所指one-time-code)之后,服务端一直提示:
object(Google_AuthException)#27 (7) {
["message":protected]=>
string(60) "Error fetching OAuth2 access token, message: 'invalid_grant'"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(400)
["file":protected]=>
string(92) "/google-api-php-client-read-only/src/auth/Google_OAuth2.php"
... ...
我使用javascript重新实现one-time-code flow却成功了。
昨天google了一天 也没解决,求指点
解决方案1:
啊!忘记了,这个问题已经自行解决啦!
被官方文档误导了。文档中的Your server's OAuth 2.0 client ID
就是在Google开发者控制台中create ios application的时候生成的client id。
问题出在服务端的redirecturi设置有误,正确的值是:$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
这个参数是固定的。
详细的资料我写到自己的博客上了 (还在整理中。)