I want to get the emails of my authorized user. Currently i am only able to get their details like name and gender but unable to get their emails. Here is the process i am following.
- Ask user to login from client side and generate a code
send that code to my server which generates access token.
$accessTokenResponse = $client->request('POST', 'https://accounts.google.com/o/oauth2/token', [ 'form_params' => $params ]);
After i get access token i call the following api to get their friend list
$profileResponse1 = $client->request('GET', 'https://www.googleapis.com/plus/v1/people/me/people/visible', [ 'headers' => array('Authorization' => 'Bearer ' . $accessToken['access_token']) ]);
Now i have the users google id but how to get their emails?
You have add scope email while building login url. In case of google-php-api like this
$client->addScope("email");