Javascript 你能在网站上从谷歌登录获得性别和d.o.b等个人资料吗?
我在我的网站上添加了谷歌登录选项,在这里我询问用户的性别和d.o.b。我如何从谷歌登录API中提取性别和d.o.b 是否有其他方法提取性别和出生日期。通过谷歌登录APIJavascript 你能在网站上从谷歌登录获得性别和d.o.b等个人资料吗?,javascript,google-api,google-oauth,google-authentication,google-data-api,Javascript,Google Api,Google Oauth,Google Authentication,Google Data Api,我在我的网站上添加了谷歌登录选项,在这里我询问用户的性别和d.o.b。我如何从谷歌登录API中提取性别和d.o.b 是否有其他方法提取性别和出生日期。通过谷歌登录API profile.gender()是我试图使用的函数。 我希望它返回用户的性别,但它没有返回任何内容 相同的代码是 <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"> </div> <script> funct
profile.gender()
是我试图使用的函数。
我希望它返回用户的性别,但它没有返回任何内容
相同的代码是
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark">
</div>
<script> function onSignIn(googleUser) { // Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail()); // The ID token you need to pass to your backend: var id_token = googleUser.getAuthResponse().id_token; console.log("I`enter code here`D Token: " + id_token); }
</script>
</body>
</html>
函数onSignIn(googleUser){//客户端脚本的有用数据:
var profile=googleUser.getBasicProfile();
console.log(“ID:+profile.getId());//不要直接将其发送到服务器!
log('Full Name:'+profile.getName());
log('给定名称:'+profile.getGivenName());
console.log('Family Name:'+profile.getFamilyName());
log(“图像URL:+profile.getImageUrl());
console.log(“Email:+profile.getEmail());//需要传递到后端的ID令牌:var ID_token=googleUser.getAuthResponse().ID_token;console.log(“I`enter code here`D token:+ID_token);}
是否有性别功能???People.get返回生日,但是只有当用户在其个人资料的共享设置中将生日设置为public时,生日才会返回
你设定的范围并不重要。他们必须把它公之于众,我相信早在google+出现的时候就已经有了这方面的功能要求
性别也是一样,默认情况下,很多个人信息都设置为私有,用户必须有目的地将其设置为公共,以便您可以在api中看到它
您能告诉我们相关代码吗?