質問

I have public Google Drive file like this one: https://docs.google.com/uc?id=0B8G77eDgeMdwMmkwcnA5eUV2M0U&export=download

I want to download that file from a Chrome Extension.

I have added these urls to the "permissions" element in the extension manifest (there are some redirects when trying to download the file and I tried to add them all): "https://*.docs.googleusercontent.com/","https://docs.google.com/","http://docs.google.com/","https://accounts.google.com/", "https://www.google.com/"

When I try to download the file Chrome returns this error:

XMLHttpRequest cannot load https://docs.google.com/nonceSigner?nonce=s35adai1lp052&continue=https://do…Ddownload%26h%3D16653014193614665626&hash=inkfclb76vcru6uuoqkfp274hk5joqk9. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

It seems I have already allowed downloads for the url in question.

If I add the <all_urls> permission the download succeeds.

Any idea what permission I need to add? Thanks in advance.

役に立ちましたか?

解決

Using for instance wget and looking at the reported redirections, you can see that the last host is something like:

doc-0c-80-docs.googleusercontent.com

The first part is probably variable, and wildcards in the host part of the URL can only match an entire part of the hostname. So you should add the following to your match patterns:

*.googleusercontent.com

他のヒント

You need at least the following minimum to access Drive files:

  • *://drive.google.com/*
  • *://*.googleusercontent.com/*
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top