@ -18,6 +18,9 @@
< / div >
< button onclick = "client.requestCode();" > Authorize with Google< / button >
<!-- <div id="testToken"></div> -->
@ -446,6 +449,34 @@
< / script >
<!-- Google auth for calendar access on first launch -->
< script src = "https://accounts.google.com/gsi/client" > < / script >
< script type = "text/javascript" >
let code_receiver_uri = "/api/google/update"
const client = google.accounts.oauth2.initCodeClient({
client_id: '186960779149-ejtu6hh3kdatlouau80h2pivt4tv3hd0.apps.googleusercontent.com',
scope: 'https://www.googleapis.com/auth/calendar.readonly',
ux_mode: 'popup',
callback: (response) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', code_receiver_uri, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + jToken);
// Set custom header for CRSF
xhr.setRequestHeader('X-Requested-With', 'XmlHttpRequest');
xhr.onload = function() {
console.log('Auth code response: ' + xhr.responseText);
};
xhr.send(JSON.stringify({"code": response.code}));
console.log(xhr)
console.log(response.code)
},
});
< / script >
< script src = "scripts.js" > < / script >
< / body >