I'm using the Google Calendar API and can't figure out how to keep the user logged in when they refresh the page. I can't find anything online about this. If anyone could help, it'd be greatly appreciated! This is my current code to login the user:
function handleAuthClick() {
tokenClient.callback = async (resp) => {
if (resp.error !== undefined) {
throw (resp);
}
await listUpcomingEvents();
};
if (gapi.client.getToken() === null) {
tokenClient.requestAccessToken({prompt: 'consent'});
} else {
tokenClient.requestAccessToken({prompt: ''});
}
}
My body element automatically runs this on load. I'm using this guide: https://developers.google.com/calendar/api/quickstart/js.