ok, here's a snippet of my code
$client = new Google_Client();
$client->setScopes(array('https://www.googleapis.com/auth/plus.me','https://www.googleapis.com/auth/userinfo.email'));
$plus = new Google_PlusService($client);
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
} else {
$_SESSION['auth_token'] = $client->authenticate();
}
and now I've got the $_SESSION['auth_token'] which contains something like
{"access_token":"ya29.AHESblablablabalbalbalbagTUI4-MfZvwtb6A","token_type":"Bearer","expires_in":3600,"id_token":"blablablabalbalbalba.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiY2lkIjoiNzAzNTg5ODA3MjMxLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXpwIjoiNzAzNTg5ODA3MjMxLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiNzAzNTgblablablabalbalbalbaRlbnQuY29tIiwiaGQiOiJnZW9mbGV4LmNvbS5teSIsInZlcmlmaWVkX2VtYWlsIjoidHJ1ZSIsImVtYWlsX3blablablabalbalbalbaFzei00N25nN3VoLU5NUmh3IiwiYXRfaGFzaCI6IllEeC13UXN6LTQ3bmc3dWgtTk1SaHciLCJpYXQiOjEzNzQ1NjA1NDcsImV4cCI6MTM3NDU2NDQ0N30.ek1FX-pY8BdaI8sDhA0rwmiIDyBV6pHPvBi-l7BxDJCR-YoDQGFN8y-kA1xg-vmoReiVCwhvQhHK__jc-xFSLfJDLbwk-UGyRKu_O7ZCaSviP7WupexIYvLGCyvgLBdjG3K7UIcq0o3L15mQPvQJr9LA7325gwEOZ12Pc1lAHKw","refresh_token":"1\/Y7oilVvUUutfkKMDfblablablabalbalbalbaE","created":1374560847}
my question is, how do I get the user's email? i know you can just call
https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=youraccess_token
but is that the 'official' way to get the users's email? because from here https://developers.google.com/accounts/docs/OAuth2Login#exchangecode it says
The Access Token that your application received during the authentication flow with Google can be used to obtain additional profile information about the user. Please be advised that Google is modifying the behavior of the different endpoints to simplify their usage. We currently recommend the following based on existing behavior. If you are using Login with Google+, you should always retrieve user profile information from the People API by sending an HTTPS GET request to https://www.googleapis.com/plus/v1/people/me using your Access Token to authenticate the request.
So i guess the best way is to perform HTTPS GET request to googleapis.com.. but I don't know how to do it. Can anyone lead the way?