Last active
February 20, 2017 00:03
-
-
Save absent1706/696057eefedc644df3b8057919e6f4de to your computer and use it in GitHub Desktop.
'SignIn with Google' button from https://developers.google.com/identity/sign-in/web/ with ready-to-go credentials
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
<!-- | |
See https://developers.google.com/identity/sign-in/web/ | |
for description and setup instructions | |
Key setup steps: | |
1. get client ID and API KEY http://www.qopy.me/0yILY0U8TD6kZ0ilhhoIAA | |
2. run HTTP server in folder where index.html lays. | |
I.g. PHP server: | |
php -S php -S 0.0.0.0:5000 | |
or this server (just EXE) http://www.zachsaw.com/?pg=quickphp_php_tester_debugger | |
You should see this page via, say, | |
http://localhost:5000 | |
3. Register this http://localhost:5000 here http://www.qopy.me/dGS1PtL9T_i3EoI8EHOwpw , http://www.qopy.me/_tCf-zeeQeupPFK0e4Dt-Q | |
--> | |
<html lang="en"> | |
<head> | |
<meta name="google-signin-scope" content="profile email"> | |
<meta name="google-signin-client_id" content="340024851095-s3044u17oksovrc5iqi8lcgr2abjj81b.apps.googleusercontent.com"> | |
<script src="https://apis.google.com/js/platform.js" async defer></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()); // Don't send this directly to your server! | |
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 ID token you need to pass to your backend: | |
var id_token = googleUser.getAuthResponse().id_token; | |
console.log("ID Token: " + id_token); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment