1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
- <meta name="google-signin-client_id" content="398214166622-jkme0i3k4tbsgqh19aejaqatrark5l94.apps.googleusercontent.com">
- <title>Login google</title>
- </head>
- <body>
- <h1>Get Google Token</h1>
- <div id="my-signin2"></div>
- <script>
- function onSuccess(googleUser) {
- console.log('Logged in as: ' + googleUser.getBasicProfile().getName());
- const idToken = googleUser.getAuthResponse().id_token;
- window.location.href = '/?id_token='+idToken
- }
- function onFailure(error) {
- alert(error);
- console.log(error);
- }
- function renderButton() {
- gapi.signin2.render('my-signin2', {
- 'scope': 'profile email',
- 'width': 240,
- 'height': 50,
- 'longtitle': true,
- 'theme': 'dark',
- 'onsuccess': onSuccess,
- 'onfailure': onFailure
- });
- }
- </script>
- <script src="https://apis.google.com/js/platform.js?onload=renderButton" async defer></script>
- <script>
- console.log({code})
- </script>
- </body>
- </html>
|