登录到多个帐户时无法使Google Drive API共享对话框正常工作 [英] Can't get Google Drive API share dialog to work when signed into multiple accounts
问题描述
使用Google Drive API在Javascript应用程序中打开共享对话框时出现JS错误。错误是:未捕获的错误:语法错误:DOM例外12.
但是,当我退出所有Google帐户并登录到一个帐户。只要我登录到新选项卡中的第二个帐户,共享对话框不再起作用,并失败,出现上述错误。
这与在Google云端硬盘SDK上调用showSettingsDialog()会引发由于X-Frame-Options 禁止显示,拒绝显示文档。但是,我已经完成了调试中显示的调试,无效,即:
相关代码是:
var shareClient = new gapi.drive.share.ShareClient(rtpg.realTimeOptions.appId);
shareClient.setItemIds([rtclient.params ['fileId']]);
shareClient.showSettingsDialog();
有没有办法让这个工作可以登录多个账户?
您可能需要仔细阅读有关x-帧问题的信息: = Google云端硬盘API,不能通过JS(x-frame-options error)打开标准共享对话框
但是我认为无法一次验证所有帐户,但是一个解决方法可能是 setOAuthToken
给他们每个人,每次你想这样做。
它在谷歌文档:
重要提示:setOAuthToken函数允许应用使用当前的
授权令牌来确定哪个Google帐户是选择器用于
显示文件。如果用户登录了多个Google帐户,则
允许选择器显示适当的
授权帐户的文件。
来源:
https://developers.google.com/drive/web/integrate-open
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.
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.
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:
- The "open with" URL that you have setup in your Google Drive SDK settings in the Google APIs Console has to have the same domain that the page where you are using the sharing dialog.
- Currently you alos need your application to be installed on your Google Drive for the embeddable widget to work. We are currently working on removing this restriction as it does not always make sense since we launched v2 of the API.
The relevant code is:
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?
you might want to read this carefully concerning the x-frame issue:
Google Drive API, can't open standard sharing dialog via JS (x-frame-options error)
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.
it is stated here in google documents that :
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.
source:
https://developers.google.com/drive/web/integrate-open
这篇关于登录到多个帐户时无法使Google Drive API共享对话框正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!