How can i get the profile and user information using google one tap signin

Viewed 275

I am trying to get the profile information using google one tap sign in and i am getting the clientId and credentials instead of users profile and i have used other gapi method also but i am not able to get it can anyone suggest how to extract

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://apis.google.com/js/platform.js" async defer></script>
    <script src="https://accounts.google.com/gsi/client" async defer></script>
    <script src="https://apis.google.com/js/client.js?onload=authorize"></script>
    <script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-firestore.js"></script>
  </head>
  <body>
    <div
      id="g_id_onload"
      data-client_id="xxxxxx"
      data-callback="handleCredentialResponse"
    ></div>
    <script>
      function handleCredentialResponse(response) {
        console.log(response);
        auth2 = gapi.auth2.init({
          client_id: "xxxxxx",
          scope:
            "email profile https://www.googleapis.com/auth/plus.business.manage",
          prompt: "none",
        });
        auth2.signIn().then(function () {
          console.log(auth2.currentUser);
        });
        auth2
          .grantOfflineAccess({
            scope:
              "email profile https://www.googleapis.com/auth/plus.business.manage",
          })
          .then(async function (resp) {
            var auth_code = resp.code;
            // here i am getting the authorization code 
          });
      }
    </script>
  </body>
</html>
0 Answers
Related