selvi jp

selvi jp

  • NA
  • 323
  • 77.3k

login with google after redirect home page and display email

May 5 2021 6:12 AM
 This code in login page.i want to show name email after login but dont know how to pass data another homepage
<script>
        function onSignIn(googleUser) {
            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());
            document.getElementById('name').innerHTML = 'Full Name:' + profile.getName();
            document.getElementById('gname').innerHTML = 'Given Name:' + profile.getGivenName();
            document.getElementById('fname').innerHTML = 'Family Name: ' + profile.getFamilyName();
            document.getElementById('image').innerHTML = "Image URL: " + profile.getImageUrl();
            document.getElementById('email').innerHTML = "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);
            localStorage.setItem("lastname", "Smith");

        }
       </script>
 
 
 
 

Answers (1)