google api和javascript。获得生日和性别

罗恩·K

我认为这很简单,但找不到示例。
我正在使用基本的Google登录示例。带有标题标签(包括生日范围):

<meta name="google-signin-scope" content="profile email https://www.googleapis.com/auth/user.birthday.read" />
<meta name="google-signin-client_id" content="xxx my id xxx" />
<script src="https://apis.google.com/js/platform.js" async defer></script>

在HTML正文中还有一个默认的登录按钮:

<div id="gsignin" class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>

和js:

  function onSignIn(googleUser) {
        var profile = googleUser.getBasicProfile();
        console.log(googleUser);
        console.log("ID: " + profile.getId());
        console.log("Name: " + profile.getName());
        console.log("Image URL: " + profile.getImageUrl());
        console.log("Email: " + profile.getEmail());
        g_token = googleUser.getAuthResponse().id_token;
  }

所有这些工作都很好,要求用户授予权限。我得到了一般的个人资料信息。但我不确定如何获取生日日期,是否以某种方式在返回的对象中?我是否需要再次调用api?
我已经看到了很多有关使用范围的示例,但是找不到实际读取数据的方法(生日)……对于性别来说,这是同样的事情,不要以为有一个特殊的范围,我想应该是基本个人资料info(?)的一部分,
谢谢

编辑:只是为了澄清,我知道我正在使用正确的范围。我不知道如何读取数据。例如,在用户通过身份验证之后-profile.getEmail()将返回电子邮件。生日会返回什么?

戴姆敦

GoogleUser.getBasicProfile()获取用户的基本个人资料信息。

返回
一个gapi.auth2.BasicProfile对象。您可以使用以下方法检索该对象的属性:
BasicProfile.getId()BasicProfile.getName()
BasicProfile.getImageUrl()
BasicProfile.getEmail()

此方法不返回生日。我唯一知道获得生日的方法是使用google + api中的people.get

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Google fit API - 个人信息 - 身高和体重的单位是什么以及我如何获得性别和生日

获取Google People个人资料API不会返回生日和性别键值

不建议使用Google Plus API。我如何从requestScopes(Scope(Scopes.PROFILE))获取性别和出生日期

Firebase网站在Google和Facebook中获取提供商数据(性别和生日)

如何使用FirebaseAuth从Google供应商获取性别和生日?

Google API 客户端和访问生日和年龄

Meetup API,如何获取性别和生日

使用Google OAuth API检索出生日期和婚姻状况

您可以从网站上的Google登录中获取性别和性别等个人资料吗?

通过Google People API的性别

通过API获得Google for business的所有评论和评分

Google API和AppsScript

Javascript和Google Chrome

如何从Android中的Facebook获取用户性别和生日

Google Places Javascript API获得响应状态

帐户关联和Google API

Google Calendar API和php

如何使用Google Map API和JavaScript查找附近的医院

如何使用 Google Maps API 从 Places 中获得一致的 City、State 和 Country 值?

使用Google Images API和CURL检索图像时,始终获得相同的链接

新的Google Play服务8.3 SignInButton打破了获取生日和名字/姓氏的功能

注册时验证用户的生日,但不验证Ruby on Rails中的Facebook和Google登录名

Google CalDAV API和Google Calendar API之间的区别

google api 和 google rest api 之间的区别?

Google Map地理编码在Forward API和Reverse API中获得不同的结果-在某些地址中

Google People API在scopes.profile中出现性别错误

Google Maps API和显示位置

Google Search API QueryOptions和SortOptions限制

验证和使用 Google Cloud Speech API