2014-10-02 56 views
2

谷歌与他们在该文件sharing dialog一个问题,如果一个用户登录到多个帐户它会旋转,然后报告“......在这个时候不可用......”谷歌API检测多个帐户登录

这已经在堆栈中报告,例如 Can't get Google Drive API share dialog to work when signed into multiple accounts和谷歌正在计划修复。

在此期间,我试图找到一种方法,可以可靠地检测用户是否登录到多个帐户,使我只能在对话框工作时显示共享选项。任何人都可以建议一种方法来检测多个登录?

回答

2

除非您通过OAuth授权每个帐户(这是不可接受的方法),否则无法检查用户是否登录到多个帐户。这是我的可怕的变通办法这个错误。

免责声明:
1.这是一个setTimeout观察家:(
2.这依赖于一个事实的用户使用的是英语语言环境:(:(
3.这依赖于一个事实,即文本正是:。Sorry, sharing is unavailable at this time. Please try again later. :(:(:(

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()显示共享对话框后面一个成功的消息。如果方法失败,我关闭对话框的份额。如果方法成功,用户将克隆在对话&看到我的成功消息。

+0

哎哟,确实......太可怕了。很可能我需要去的深度。我需要考虑这一点 - 非常感谢你发布。 – bleeper 2014-10-09 10:55:58