小编Cas*_*Cas的帖子

gapi.auth2 已经用不同的选项初始化。考虑调用 gapi.auth2.getAuthInstance() 而不是 gapi.auth2.init()

我需要连接到多个帐户的多个 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)

javascript google-authentication

8
推荐指数
1
解决办法
983
查看次数

标签 统计

google-authentication ×1

javascript ×1