dongyisa6254 2015-08-20 04:41
浏览 59
已采纳

Google的登录PHP API不会返回用户信息

I'm truly baffled on this one. I have a site with login and everything already implemented, but now I want to add a google login. So I've been doing it using the Google PHP API and a user can login and everything, but whenever I try to call:

$payload = $this->client->verifyIdToken()->getAttributes();

No errors are thrown, but an empty array is returned.
Everything works fine, the code Google returns validates, the token is validated after that, and it's all fine and good, but this is empty.

The scope is:

$this->client->setScopes('email');
  • 写回答

1条回答 默认 最新

  • dqd22496 2015-08-24 01:55
    关注

    try to change the scope to this:

    $this->client->setScopes(array('https://www.googleapis.com/auth/plus.login','https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me'));
    

    This works for my current project.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题