Last active
September 29, 2023 08:02
-
-
Save bipoza/b623814dfa0e9c9c2f35585458d29e8f to your computer and use it in GitHub Desktop.
Google Login with Javascript
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Hello Analytics - A quickstart guide for JavaScript</title> | |
</head> | |
<body> | |
<h1>GOOGLE LOGIN</h1> | |
<script> | |
var CLIENT_ID = 'YOUR_CLIENT_ID'; | |
window.onload = function () { | |
const client = google.accounts.oauth2.initTokenClient({ | |
client_id: CLIENT_ID, | |
scope: | |
'https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/analytics.edit', | |
callback: (response) => { | |
console.log('response: ', response.access_token); | |
}, | |
}); | |
client.requestAccessToken(); | |
}; | |
</script> | |
<script src="https://accounts.google.com/gsi/client" async></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment