【问题标题】:getting blank name (display name) from google plus api从google plus api获取空白名称(显示名称)
【发布时间】:2015-02-07 12:46:21
【问题描述】:

我正在开发登录系统,用户使用 google plus api 登录到网站。我在令牌验证后点击“我”端点。但在某些情况下我遇到了一个问题,我没有得到用户的 displayName/Name 对象。 使用的范围:plus.profile 和 plus.login Endpint命中:“我”

$service=new Google_Service_Plus($client);
    $userinfo=$service->people->get('me');

我想获取用户的用户名。

【问题讨论】:

  • 是否与特定用户一致?你能用APIs Explorer 复制它吗?您确定您没有收到您未捕获的请求的错误吗?
  • @abraham:是的,我什至没有在 API explorer 中得到结果。问题是我正在为某些帐户而不是其他帐户获取 displayName。如果用户还没有 google plus 帐户,有什么方法可以强制他创建 google plus 帐户。
  • 我得到了那些不是 google plus 用户的空白名称。有没有办法让用户在登录应用程序之前创建一个 google plus 帐户。
  • 您在登录流程中要求什么scopes
  • 我正在使用 plus.email 和 plus.profile 范围。我想我需要使用已弃用的 userinfo.email 和 userinfo.profile 范围,以迫使用户在他的 gmail 帐户未链接到 google plus 帐户时创建新的 google plus 个人资料。

标签: google-api google-plus google-api-php-client google-api-client


【解决方案1】:

Google+ 登录为所有拥有 Google 帐户的用户提供支持,即使他们尚未创建 Google+ 个人资料。您的应用可以提示这些用户创建 Google+ 个人资料(通过使用 https://www.googleapis.com/auth/plus.login 范围)或不(通过使用个人资料范围)

Switch to Google+ Sign-In

如果您使用 https://www.googleapis.com/auth/plus.login 范围,则可以保证用户拥有 Google+ 个人资料。

【讨论】:

    【解决方案2】:

    如果您想提供有关个人资料(姓名)和电子邮件的信息。

    我建议您添加以下由两个空格分隔的范围:

    profile  email
    

    profile 提供姓名(givenName、familyName 等),email 提供电子邮件。

    【讨论】:

      猜你喜欢
      • 2012-02-05
      • 2020-03-02
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 2017-07-20
      • 1970-01-01
      • 2012-02-05
      相关资源
      最近更新 更多