调用 realtime.loadAppDataDocument 后,我收到错误:
XMLHttpRequest cannot load https://drive.google.com/load?
access_token=ya29.AHES6ZRoDqY0PmpHlbUjniB8wIl… Kzw
&id=1xAp1SMlamIfjnUGO9pDwfNF5IphdtnZsCw36KalJss27wy00LJ-rCN9MpcHMx408Xg.
Origin http://localhost:4567 is not allowed by Access-Control-Allow-Origin.
但是,如果我使用 fileid 调用 realtime.load 它可以工作。请参阅下面的代码摘录
if (fileId === null) {
// this call fails
gapi.drive.realtime.loadAppDataDocument(onFileLoaded, initializeStorageModel, handleErrors);
} else {
// this call succeeds
gapi.drive.realtime.load(fileId, onFileLoaded, initializeStorageModel, handleErrors);
}
在此之前使用的变量(传递给 google 以获取访问令牌):
LOAD_APIS = 'auth:client,drive-realtime,drive-share';
SCOPE = [
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.file'
];
LOAD_CLIENT_APIS = ['drive', 'v2'];
有谁知道如何让 realtime.loadAppDataDocument 方法工作?
更新:我认为该请求可能实际上收到了 401 响应(但由于 CORS 标头未与 401 响应一起发送,因此调用了 Access-Control-Allow-Origin 错误)