Google 的文档 sharing dialog 有问题如果用户登录多个帐户,它将旋转并报告“...此时不可用...”
这已在 stackoverflow 中报告,例如 Can't get Google Drive API share dialog to work when signed into multiple accounts Google 正在计划修复。
在此期间,我试图找到一种能够可靠地检测用户是否登录到多个帐户的方法,使我能够仅在对话框正常工作时显示共享选项。任何人都可以建议一种检测多次登录的方法吗?
最佳答案
除非您通过 OAuth 授权每个帐户(这不是可接受的方法),否则您无法检查用户是否登录了多个帐户。这是我针对此错误的可怕解决方法。
免责声明:
1. 这是一个 setTimeout
观察者:(
2. 这取决于用户使用英语语言环境的事实:( :(
3. 这依赖于文本恰好是:抱歉,目前无法共享。请稍后重试。
:( :( :(
var TIME_LIMIT_SECONDS = 35;
var errorTimer = null;
var startTime = null;
// Call this function after you call showSettingsDialog()
function watchForErrors() {
startTime = new Date().getTime();
startErrorTimer();
};
// Starts the error check
function startErrorTimer() {
errorTimer = setTimeout(function () {
var $test = $(".dcs-cd-dcs-c-dcs-eb").filter(function () { return $(this).text().trim() === "Sorry, sharing is unavailable at this time. Please try again later."; });
if ($test.length) {
// Message detected...do something
console.log("Error Found!");
// Close the share dialog
$("span.dcs-cd-dcs-c-dcs-k-dcs-bc[role='button']").trigger("click");
return;
}
if ((new Date().getTime() - startTime) / 1000 < TIME_LIMIT_SECONDS) {
// No errors detected. Could be a success at this point
startErrorTimer();
} else {
// No errors found after 35 seconds - probably a success?
console.log("Timeout - Success?");
}
}, 200);
};
我所做的就是在调用 showSettingsDialog()
后立即在共享对话框后面显示一条成功消息。如果该方法失败,我会关闭共享对话框。如果该方法成功,用户将关闭对话框并查看我的成功消息。
关于google-chrome - Google API 检测多帐户登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26162249/