我需要连接到多个帐户的多个 Google 议程以获取事件。为要连接的每个议程调用以下函数,它适用于第一个查询的帐户,之后出现上述错误。如何连接到下一个帐户,身份验证是否需要断开连接或取消设置?
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));
});
}
}
Run Code Online (Sandbox Code Playgroud)