-1

I'm using this code https://github.com/google/google-api-php-client the user-example.php in the examples folder, to make some tests on Google plus signin.

Everything worked well, except one thing. After the connection, i obtained this url :

http://MYURL/?code=4/vt_b0DsUU91UOYkB3ozIp-ZLITiL2irzaaUzyvtdph4.4gAL4kfDZGUVJvIeHux6iLafIxOglAI

My question is, where can i get the user email ?

Thanks

DidIReallyWriteThat
  • 1,033
  • 1
  • 10
  • 39
user
  • 539
  • 1
  • 11
  • 32
  • First of all, you should use a library, etc. for convenience. Furthermore the point of G+ signin is to hide that information from websites. It this allows users to remain anonymous. The URL however contains a token and depending on the access a user has given, you can access the email address. – Willem Van Onsem Dec 16 '14 at 01:04
  • What kind of library? And how do i get the email address ? – user Dec 16 '14 at 01:17

1 Answers1

0

TL;DR: Fully working solution: Get Userinfo from Google OAuth 2.0 PHP API

You're using offline flow which is described in details here: https://developers.google.com/accounts/docs/OAuth2WebServer#handlingtheresponse

At this point you got code.

vt_b0DsUU91UOYkB3ozIp-ZLITiL2irzaaUzyvtdph4.4gAL4kfDZGUVJvIeHux6iLafIxOglAI

This code needs to be exchanged for access_token.

Exchanging code for access token using Google Library: https://github.com/google/google-api-php-client/blob/master/examples/user-example.php#L66

With access_token you can send api requests.

Community
  • 1
  • 1
Jarosław Gomułka
  • 4,935
  • 18
  • 24