如何在Php中使用google Oauth2.0打印UserInfo


How to print UserInfo with google Oauth2.0 in Php

如果
https://www.googleapis.com/auth/userinfo.profile 范围已弃用

"google-api-php-client/src/contrib/Google_Oauth2Service.php"文件夹不再存在

我想打印用户名,电子邮件...

我该怎么做?

https://www.googleapis.com/auth/userinfo.profile作用域已替换为profile作用域,因此客户端应请求后者。

我找到了解决方案:将范围替换为用户信息,如 https://www.googleapis.com/auth/userinfo.profile

有了那个:

$client->addScope("https://www.googleapis.com/auth/plus.login"); $client->addScope("https://www.googleapis.com/auth/plus.profile.emails.read");

它有效!