How can I get email address from Google Plus API once i got the token

烂漫一生 提交于 2019-12-04 06:34:21

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!