0

I using this code to retrive file from google drive picker. But on IE browser it return error on call.

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

In Chrome and Firefox works OK, but in IE 11 and + returns "Access denied". Error print screen

1 Answers1

0

If you're using IE6 or any old browsers, you'll need to use a specific rpc_relay file and place it in the same domain of your application and then modify its creation code.

Supporting Older Browsers

  1. Download this file: https://www.google.com/ajax/picker/resources/rpc_relay.html.
  2. Place the file somewhere in the same domain as you application.
  3. Modify the Picker creation code, using the corrected path:

    var picker = new google.picker.PickerBuilder().
        addView(google.picker.ViewId.IMAGE_SEARCH).
        setDeveloperKey(developerKey).
        setCallback(pickerCallback).
        setRelayUrl('http://www.yoursite.com/somedir/rpc_relay.html').
        build();
    

More information about the Picker API can be found in its documentation

adjuremods
  • 2,938
  • 2
  • 12
  • 17