Last active
May 9, 2018 16:53
-
-
Save josephkandi/002d37aa8d4ac09716306c13130f0f69 to your computer and use it in GitHub Desktop.
This file contains 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
var auth2; | |
var loggedInPara = document.getElementById('login-status'); | |
gapi.load('auth2', function(){ | |
auth2 = gapi.auth2.init({ | |
client_id: 'app-id.apps.googleusercontent.com' | |
}); | |
loggedInPara.textContent = (auth2.isSignedIn.get()) ? 'User is logged in' : 'User is logged out'; | |
auth2.attachClickHandler('signin-button', {}, onSuccess, onFailure); | |
}); | |
var onSuccess = function(user) { | |
console.log('Signed in as ' + user.getBasicProfile().getName()); | |
}; | |
var onFailure = function(error) { | |
console.log(error); | |
}; | |
function signOut() { | |
auth2.signOut().then(function () { | |
console.log('User signed out.'); | |
}); | |
} | |
function isLoggedIn(){ | |
return auth2.isSignedIn.get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment