我正在使用来自的谷歌登录示例https://developers.google.com/identity/sign-in/web/ https://developers.google.com/identity/sign-in/web/(下面粘贴的代码供后代使用)。
<html lang="en">
<head>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<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("ID Token: " + id_token);
};
</script>
</body>
</html>
默认情况下,这会请求“电子邮件”和“个人资料”范围。这意味着当我的用户被要求授权我登录时,它会说To continue, Google will share your name, email address, and profile picture with <app name>
。但是,我只需要他们的电子邮件地址,并且不想让他们怀疑我将如何处理他们的个人资料图片等。
我尝试过仅询问电子邮件,并使用以下代码明确禁用基本个人资料信息,但这不会改变谷歌登录页面给出的消息。
<meta name="google-signin-scope" content="email">
<meta name="google-signin-fetch_basic_profile" content="false">
如何请求我的用户的电子邮件地址而不让谷歌警告他们我也可以访问他们的个人资料信息和照片?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)