Only fetch email using google-signin

我只是一个虾纸丫 提交于 2020-01-03 05:26:07

问题


I'm using the google sign-in example from https://developers.google.com/identity/sign-in/web/ (code pasted below for posterity).

<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>

By default this requests both 'email' and 'profile' scopes. This means when my users are asked to authorise my the login, it says To continue, Google will share your name, email address, and profile picture with <app name>. However, I only need their email address, and don't want to put them off wondering what I'm going to do with their profile picture etc.

I've tried asking only for email and also explicitly disabling basic profile info using the following code, but this doesn't change the message that the google sign-in page gives.

<meta name="google-signin-scope" content="email">
<meta name="google-signin-fetch_basic_profile" content="false">

How can I request my users email address without google warning them that I'll have access to their profile info and picture too?

来源:https://stackoverflow.com/questions/51965244/only-fetch-email-using-google-signin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!