Skip to content

Instantly share code, notes, and snippets.

@javorosas
Created July 18, 2016 23:43
Show Gist options
  • Save javorosas/0f2455c15a45ef88270b8c76f39a1592 to your computer and use it in GitHub Desktop.
Save javorosas/0f2455c15a45ef88270b8c76f39a1592 to your computer and use it in GitHub Desktop.
Google sign in example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google Login</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="764821343773-cjpf8lnubnnmjrupiu8oen4vsacgcq9n.apps.googleusercontent.com">
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script>
function onSignIn(googleUser) {
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());
console.log(googleUser.getAuthResponse().id_token)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment