I need to connect to several Google agendas accross several accounts to get events. The below function is called for each agenda to be connected to, it works for the first queried account, afterwards I get the above error. How can I connect to the next accounts, is there some disconnection or unsetting necessary for the authentication?
function runClient(apikey, client_id, calendar_id, post_id){
gapi.load('client:auth2', initClient);
function initClient() {
gapi.client.init({
discoveryDocs: ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"],
}).then(() => {
gapi.auth2.init({
client_id: client_id,
apiKey: apikey,
scope: "https://www.googleapis.com/auth/calendar.readonly",
}).then(getUpcomingEvents(calendar_id, post_id));
});
}
}