gpt4 book ai didi

javascript - 登录多个帐户时无法使用 Google Drive API 共享对话框

转载 作者:行者123 更新时间:2023-12-02 22:22:47 35 4
gpt4 key购买 nike

我在使用 Google Drive API 在 Javascript 应用程序中打开共享对话框时遇到 JS 错误。错误是:未捕获错误:语法错误:DOM 异常 12。

但是,当我注销所有 Google 帐户然后仅登录一个帐户时,共享对话框可以正常工作。一旦我在新选项卡中登录第二个帐户,共享对话框就不再工作并失败并出现上述错误。

这与 Calling showSettingsDialog() on the Google Drive SDK throws a Refused to display document because display forbidden by X-Frame-Options 非常相似。但是,我已经完成了接受的响应中显示的调试,但无济于事,即:

  • 您在 Google API 控制台的 Google Drive SDK 设置中设置的“打开方式”网址必须与您使用共享对话框的页面具有相同的域。
  • 目前,您还需要将应用程序安装在 Google 云端硬盘上,嵌入式小部件才能正常工作。我们目前正在努力消除此限制,因为自从我们推出 API v2 以来,它并不总是有意义。

相关代码为:

var shareClient = new gapi.drive.share.ShareClient(rtpg.realTimeOptions.appId);
shareClient.setItemIds([rtclient.params['fileId']]);
shareClient.showSettingsDialog();

是否有某种方法可以在登录多个帐户的情况下实现此功能?

最佳答案

您可能需要仔细阅读有关 x 框架问题的内容:

Google Drive API, can't open standard sharing dialog via JS (x-frame-options error)

但我认为不可能一次验证所有帐户,但解决方法可能是每次您想要这样做时都为每个帐户setOAuthToken

谷歌文档中指出:

Important:The setOAuthToken function allows an app to use the current auth token to determine which Google account the picker uses to display the files. If a user is signed into multiple Google accounts, this allows the picker to display the files of the appropriate authorized account.

来源:

https://developers.google.com/drive/web/integrate-open

关于javascript - 登录多个帐户时无法使用 Google Drive API 共享对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15664523/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com