【问题标题】:How to retrieve user's name from Google API如何从 Google API 检索用户名
【发布时间】:2019-03-03 23:06:41
【问题描述】:

我正在以这种方式进行 Google OAuth 登录:

let instance = gapi.auth2.getAuthInstance();
  instance.signIn({
    scope: 'profile email https://www.googleapis.com/auth/plus.me'
  }).then((user) => {
    this.makeGoogleLogin(user.getAuthResponse().id_token);
  });

我只想获取姓名、电子邮件和性别。

此代码有效,但由于 Google+ API 于 3 月 7 日关闭,我不知道如何检索用户名。 我查看了 Google API 但找不到。

您知道如何从 Google 检索用户名吗?

【问题讨论】:

    标签: javascript google-api


    【解决方案1】:

    您可以通过people API. 这将返回有关当前已验证用户的信息

     GET https://people.googleapis.com/v1/{resourceName=people/*}
    

    发送资源名称 =people/me

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 2014-02-25
      • 2016-05-18
      • 2012-01-06
      • 2013-12-11
      • 2015-07-28
      相关资源
      最近更新 更多