登录多个帐户时无法使 Google Drive API 共享对话框工作 [英] Can't get Google Drive API share dialog to work when signed into multiple accounts

查看:23
本文介绍了登录多个帐户时无法使 Google Drive API 共享对话框工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having a JS error when opening a share dialog in a Javascript application using the Google Drive API. The error is: Uncaught Error: Syntax Error: DOM Exception 12.

但是,当我退出所有 Google 帐户然后只登录一个帐户时,共享对话框可以正常工作.当我在新标签页中登录第二个帐户后,共享对话框将不再起作用,并因上述错误而失败.

However, the sharing dialog works fine when I log out of all Google accounts and then log into just one account. As soon as I log into a second account in a new tab, the sharing dialog no longer works and fails with the above error.

这与 非常相似在 Google Drive SDK 上调用 showSettingsDialog() 会引发拒绝显示文档,因为 X-Frame-Options 禁止显示.但是,我已经完成了接受响应中显示的调试,但无济于事,即:

This is very similar to Calling showSettingsDialog() on the Google Drive SDK throws a Refused to display document because display forbidden by X-Frame-Options. However, I have done the debugging shown in the accepted response to no avail, namely:

  • 您在 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();

有没有办法让登录的多个帐户也能正常工作?

Is there some way to make this work with multiple accounts signed in?

推荐答案

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

you might want to read this carefully concerning the x-frame issue:

谷歌Drive API,无法通过 JS 打开标准共享对话框(x-frame-options 错误)

但我认为不可能一次对所有帐户进行身份验证,但每次您想要这样做时,可能有一种解决方法setOAuthToken 对每个帐户进行身份验证.

but what i think it is not possible to authenticate all the accounts at once , but a workaround maybe to setOAuthToken to each of them everytime you want to do so.

在 google 文档中说明:

it is stated here in google documents that :

重要提示:setOAuthToken 函数允许应用使用当前身份验证令牌,用于确定选择器使用哪个 Google 帐户显示文件.如果用户登录了多个 Google 帐户,这允许选择器显示适当的文件授权帐号.

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

这篇关于登录多个帐户时无法使 Google Drive API 共享对话框工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆