0

I am using the Google API to sign in users . They can sign in but i need to then send the information to the server side code from the client side

I'm not to sure how to approach this, i have looked at sending data from client side to server side but i couldn't find a solution

here is my HTML

<!-- sign in button -->
<div id="signin" class="g-signin2" data-onsuccess="onSignIn"></div>
<!-- The client sided function -->
<script>
  function onSignIn(googleUser) {
    // get user profile information
    console.log(googleUser.getBasicProfile())
    var profile = googleUser.getBasicProfile();
    console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
    console.log('Name: ' + profile.getName());
    console.log('Image URL: ' + profile.getImageUrl());
    console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
    document.getElementById("signin").style.display = "none"
    document.getElementById("signout").style.display = "block"
  }
</script>

Is there a way that I can send googleUser.getBasicProfile() to my server side code, or just have the onSignIn() function server side and it runs that

ziganotschka
  • 25,866
  • 2
  • 16
  • 33

0 Answers0