Search code examples
google-drive-apigoogle-drive-realtime-api

Call to realtime.loadAppDataDocument fails when realtime.load works?


After calling realtime.loadAppDataDocument I receive the error:

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. 

However if I call realtime.load with a fileid it works. See code extract below

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);
}   

Variables being used before this point (passed to google for the access token):

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'];

Does anyone know how to get the method realtime.loadAppDataDocument to work?

Update: I think the request may be actually receiving a 401 response (but because the CORS header isn't sent with the 401 response the Access-Control-Allow-Origin error is called)


Solution

  • Google pushed some changes to the Realtime API which has fixed the problem.