Last active
January 25, 2021 10:47
-
-
Save gent-fella-health/2ecc1fbb6b2dfabe634e532afbf82f48 to your computer and use it in GitHub Desktop.
GOOGLE LOGIN HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<meta name="google-signin-scope" content="profile email"> | |
<meta name="google-signin-client_id" content="{client_id}"> | |
<script src="https://apis.google.com/js/platform.js" async defer></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></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()); | |
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 token you need to pass to your backend: | |
let accessToken = googleUser.getAuthResponse().access_token; | |
// Send request to backend: | |
axios.post('{backend_url}', {accessToken: accessToken}).then(function (response) { | |
console.log(response) | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment