0

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 ?

Ghaffe
  • 13
  • 2

2 Answers2

0

The https://www.googleapis.com/auth/userinfo.profile scope was replaced with the profile scope so your client should request the latter.

Hans Z.
  • 50,496
  • 12
  • 102
  • 115
  • But how to access to the lastname, firstname is it some sort of Array ? – Ghaffe Dec 29 '14 at 09:53
  • you can access `https://www.googleapis.com/plus/v1/people/me` with a proper credential and then a JSON object is returned that contains so-called claims as in `{ "displayName": "John Jones", "name": { "familyName": "Jones", "givenName": "John" }, }` so you'd access lastname as `$response["name"]["familyName"]` – Hans Z. Dec 29 '14 at 15:05
0

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 !

Ghaffe
  • 13
  • 2