I have got accesstoken using oauth2.0. I am able to get the person name, gender, etc but I am not able to get the email address of the user.
Could any one please paste some sample code or any suggestions on how to get the email address from the google plus API?
You can retrieve a user's email address if they specifically authorize your application to see their email address.
Set your scopes to:
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/userinfo.email
The JavaScript calls look like this:
gapi.client.load('oauth2', 'v2', function() {
gapi.client.oauth2.userinfo.get().execute(function(resp) {
// Shows user email
console.log(resp.email);
})
});
gapi.client.load('plus', 'v1', function() {
gapi.client.plus.people.get( {'userId' : 'me'} ).execute(function(resp) {
// Shows other profile information
console.log(resp);
})
});
More information https://developers.google.com/+.
Note that you do not need scopes for plus.me or userinfo.profile.
Exposing E-mail addresses of people who have not set it to be visible to 'Public' would obviously be a privacy issue, so that's not possible.
Exposing E-mail addresses of people who have set their E-mail address visibility to 'Public' is possible, but not yet there. It is currently an open issue
Edit: The issue is resolved now, so you can follow the steps in the other answer to get it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With