Search code examples
phpoauth-2.0openidgoogle-api-php-clientuserinfo

How to print UserInfo with google Oauth2.0 in Php


How can I print UserInfo with the latest version of google Oauth 2.0
if https://www.googleapis.com/auth/userinfo.profile scope is deprecated

"google-api-php-client/src/contrib/Google_Oauth2Service.php" Folder doesn't exist anymore

I want to print username, email ...

How can I do this ?


Solution

  • I found the solution : replace scopes with Userinfo like https://www.googleapis.com/auth/userinfo.profile

    with that :

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

    And It Works !