Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created October 16, 2015 15:49
Show Gist options
  • Save AndyNovo/38b1846fe59a962f6fbc to your computer and use it in GitHub Desktop.
Save AndyNovo/38b1846fe59a962f6fbc to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<meta name="google-signin-client_id" content="CUSTOM_ID_HERE.apps.googleusercontent.com">
<title>CAS Test</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<h1>Hi there</h1>
<h2>Please sign in with one of our authentication services:</h2>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<h3 id="user-data" class="logged-out">Hello there <span id="username">Your Name Here</span></h3>
<h6 id="log-out">Log Out Of This App</h6>
</body>
<script type="text/javascript">
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
document.getElementById("username").innerHTML = profile.getName() +
"<hr><img src=\""+profile.getImageUrl()+"\"/>";
document.querySelector("#user-data").classList.remove("logged-out");
console.log('Email: ' + profile.getEmail());
}
document.getElementById("log-out").addEventListener("click", signOut);
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
document.querySelector("#user-data").classList.add("logged-out");
});
}
</script>
<style>
.logged-out {
display: none;
}
</style>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment