开发者社区> 问答> 正文

IOS使用google+登陆提示 invalid_grant

公司的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了一天 也没解决,求指点

展开
收起
a123456678 2016-07-27 15:54:26 3268 0
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');
    这个参数是固定的。

    2019-07-17 20:00:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载