如何从Google API检索用户名

时间:2019-03-03 08:26:27

标签: javascript google-api

我通过这种方式进行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检索用户名?

1 个答案:

答案 0 :(得分:0)

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

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

发送resorcename = people / me