小编Sup*_*n79的帖子

Google Drive API:下载文件出现lockedDomainCreationFailure 错误

我正在尝试使用 Google Drive 文件选择器下载文件(基于此示例https://gist.github.com/Daniel15/5994054)。文件选择器在下载文件时工作良好。它遇到 400 Bad-Request (lockedDomainCreationFailure) 错误。

这是代码:

function downloadFile(file, callback) {
  if (file.downloadUrl) {
    var accessToken = gapi.auth.getToken().access_token;
    var xhr = new XMLHttpRequest();
    xhr.open('GET', file.downloadUrl);
    xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken);
    xhr.onload = function() {
      callback(xhr.responseText);
    };
    xhr.onerror = function() {
      callback(null);
    };
    xhr.send();
  } else {
    callback(null);
  }
}
Run Code Online (Sandbox Code Playgroud)

这是错误消息:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "lockedDomainCreationFailure",
    "message": "The OAuth token was received in the query string, which this API forbids for response …
Run Code Online (Sandbox Code Playgroud)

javascript google-api oauth-2.0 google-drive-api google-drive-picker

1
推荐指数
1
解决办法
879
查看次数