1

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)

Jake Bolam
  • 388
  • 3
  • 10
  • Hi Jake - are you by chance using Safari? This feature depends on redirects which unfortunately don't work in Safari with CORS XHRs (http://stackoverflow.com/questions/15093281/safari-ajax-cors-request-not-following-redirect). This is in fact the same issue that caused realtime.load to fail on Safari last week. We were able to find a workaround for realtime.load, but unfortunately we don't have a workaround for realtime.loadAppDataDocument. The good news is that we do have a fix for this feature on Safari which should be live next Wednesday. – Brian Cairns Aug 14 '13 at 18:25
  • Hey Brian, this is with Chrome on Mac, (and a quick test shows that Chrome on Windows also fails). (I'm unable to test I.E. because I am not yet running over (SSL)) – Jake Bolam Aug 15 '13 at 00:28
  • 401 usually indicates that authorization failed, although I'm not certain why you would see that for realtime.loadAppDataDocument but not for realtime.load unless you are missing the drive.appdata scope (which you aren't, at least according to the code). Unfortunately I wasn't able reproduce your issue in my test app. Are you able to share the full code? – Brian Cairns Aug 16 '13 at 20:17
  • Hey Brian, I've put up a temporary waterd down version of the app here: http://pacific-plains-7355.herokuapp.com/ (ignore the https errors, and also due to not having https this will fail in IE) just note the two Origin errors. – Jake Bolam Aug 20 '13 at 10:27
  • PS: If I remove the drive.appdata from scope I get the 403 response. – Jake Bolam Aug 20 '13 at 10:34
  • The test app seems to load correctly for me. We pushed some changes yesterday that may have fixed your issue - would you mind giving it another try? – Brian Cairns Aug 21 '13 at 21:20
  • Brian the changes yesterday have fixed the problem! – Jake Bolam Aug 22 '13 at 01:41

1 Answers1

0

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

Jake Bolam
  • 388
  • 3
  • 10