Google+ api:获取用户备用电子邮件地址

Google+ api: Get users alternate email addresses

本文关键字:备用 电子邮件地址 用户 获取 api Google+      更新时间:2023-09-26

我使用javascript将'Sign in with Google+'添加到一个网站。

使用以下代码

gapi.client.load('plus','v1', function(){
  var request = gapi.client.plus.people.get({
       'userId': 'me'
     });
     request.execute(function(resp) {
       console.log(resp);
     });

我的HTML是这个

<div id="gSignInWrapper"><div id="customBtn" class="customGPlusSignIn"> 
<span class="icon"></span> <span class="buttonText"><strong>Login</strong> with Google+</span>
</div>
</div>

我的页面底部有这个:

var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
       //po.src = 'https://apis.google.com/js/client:plusone.js';
       po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
       var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
     })();
function render() {
    gapi.signin.render('customBtn', {
      'callback': 'signinCallback',
      'clientid': '410303772734-t1k0lsm5f83lvrpbglgdbu71kj8gqsdv.apps.googleusercontent.com',
      'cookiepolicy': 'single_host_origin',
      'requestvisibleactions': 'http://schema.org/AddAction',
      'scope': 'https://www.googleapis.com/auth/plus.profile.emails.read'
    });`

这一切都创建了按钮,我可以登录ok。

登录响应包括
..."emails":[{"value":"mine@gmail.com","type":"account"}], ...

从Google返回的数据包括一个名为email的数组。该数组仅包含与我的帐户关联的Primary电子邮件地址。我如何获得与该帐户相关的所有其他电子邮件?肯定还有其他的邮件,我今天自己加的。

我检查了以下内容,但似乎没有答案:

  • 通过电子邮件地址从Google Plus中提取用户详细信息
  • 谷歌OAuth API获取用户的电子邮件地址?
  • 如何在google plus API中获得电子邮件地址和人员列表
  • https://developers.google.com/+/api/oauth

为了出现在API响应中,电子邮件必须是公开的。但是,API似乎没有返回邮件列表。

下面的测试演示应该工作,但我看到的和你一样。我会跟进的