Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied ... Maybe you need to change permission over 'Anyone with the link'? #43

Open
alexklwong opened this issue Mar 25, 2020 · 128 comments · Fixed by #308
Open
Labels
bug for issue

Comments

@alexklwong
Copy link

I want to download a 16GB zip file on Google Drive using:

gdown https://drive.google.com/uc?id=1InfIal4y7OBMGNUDeldEmDxtD0MrewY8

I have already set the permissions on the file to ``Anyone with the link''

But I get this error:

Permission denied: https://drive.google.com/uc?id=1InfIal4y7OBMGNUDeldEmDxtD0MrewY8
Maybe you need to change permission over 'Anyone with the link'?

@mrlzla
Copy link

mrlzla commented Mar 25, 2020

The same error

@zenithfang
Copy link

same error

@wkentaro
Copy link
Owner

wkentaro commented Mar 31, 2020

Maybe the same issue as #26.

I found this happens with large data + many access (e.g., public dataset) #42. However, I have no idea how to fix this.

If they are the same issue, there's no solution at the moment from gdown side.

@Rmao99
Copy link

Rmao99 commented Mar 31, 2020

I have this issue as well with a 15GB dataset and a 4.3 GB dataset. But when I copy the 4.3GB to my local drive and manually get the link on my copied dataset it works. Can't make a copy of the 15GB on free drive though.

For reference the datasets im downloading are:
https://drive.google.com/file/d/1NrqOLbMa_RwHbG3KIXJFWLnlND2kiIpj/view
https://drive.google.com/file/d/15w0q3Nuye2ieu_aUNdTS_FNvoVzM4RMF/view

I was actually able to successfully download both datasets once from the original links but after needing to redo the downloads they no longer work even when uninstalling and reinstalling gdown

@wkentaro
Copy link
Owner

wkentaro commented Mar 31, 2020

@Rmao99 Thanks for the information. That behavior makes sense if that's the issue of Google-Drive's side. It seems they restrict access from the command-line for data with many access (e.g., public dataset).

@wkentaro
Copy link
Owner

I've added a new feature to keep cookies #51.
I hope this fixes this issue.

You can try pre-released version of this.

pip install -U --no-cache-dir gdown --pre

by default, cookies is enabled and saved into ~/.cache/gdown/cookies.json.
You can disable it by gdown --no-cookies XXX

@Jackie-LJQ
Copy link

Jackie-LJQ commented May 5, 2020

I have the same issue. I tried the above version, not fix.

@whulixiya
Copy link

I met the same error when I try to download many big files from my google drive, have anyone fixed it?

@carlmalamud
Copy link

carlmalamud commented Jun 3, 2020

I find if I rm ~/.cache/gdown/cookies.json and then restart my script, things start downloading again. Is your cookie expiring perhaps? I'm good for 1,000 or so files before I get the error.

Thanks for gdown. Very helpful!

@wkentaro
Copy link
Owner

wkentaro commented Jun 3, 2020

@carlmalamud Thanks for info. Do you have any sharable links to reproduce this?

@whulixiya
Copy link

whulixiya commented Jun 4, 2020 via email

@carlmalamud
Copy link

@wkentaro What is happening is your cookie keeps growing and growing until it is full. I believe every time there is a warning, a new line gets added. I've seen my cookie grow from 11 warnings to 36 warnings in about 2 hours. After about 1,000 files, there are presumably enough that there isn't room for more warnings, so you when present the cookie that doesn't mention a particular download, Google rejects it and your code is thinking that it is a permission issue.

Perhaps if your cookie fails, you could remove it, try again, and only then if it fails a second time assume it is a permissions issue.

Here is a snippet of what my cookie looks like:

[
[
"AUTH_22nmp4ombsvnvmjrl3nb3u3hsrucc95e",
"14651752893030988712Z|1591294950000|hospjjjbfh4rapv59tff247rc9fhcbr3"
],
[
"NID",
"204=x4h9LoiFMtrKRVT3aYaAXNxcePhv5SjsTw9qrioaMhrWD61BLoO_hbjosmcIBEYKSEf-pqz0U5D9SyUKwCiHJJ1Ys_xGBVg8oLqizpJaVYdWUoSIgSZKNL3xpkoGvIQs9lz8hTQD9EgvcwunJ--j5FtM7OPAn_W8mnVaHEVweSs"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQEMExkMlBpOUJoQ28",
"IcVe"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQEMmVDYVJUckNQZlE",
"Ricd"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQENGlEZDNabFRwVzg",
"579P"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQENk9JWmNMNm81R0k",
"o4Bf"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQENlVqTnJsc2R5dzA",
"osl-"
],
[
"download_warning_13058876669334088843_0B7JhzNLs-FQEOGpkZzFad25SdFE",
"8XbE"
],

@carlmalamud
Copy link

It looks like the magic number is 110 download_warnings and the cookie is full.

@wkentaro
Copy link
Owner

wkentaro commented Jun 6, 2020

@carlmalamud thanks!

@wkentaro
Copy link
Owner

wkentaro commented Jun 6, 2020

Sent a PR here: #55

@wkentaro
Copy link
Owner

wkentaro commented Jun 6, 2020

Released as v3.11.1

@wkentaro
Copy link
Owner

wkentaro commented Jun 6, 2020

@carlmalamud can you try if the new version eases the issue?

@grudloff
Copy link

Same problem, upgraded to latest release and I get the following message:

Access denied with the following error:

 	Too many users have viewed or downloaded this file recently. Please
	try accessing the file again later. If the file you are trying to
	access is particularly large or is shared with many people, it may
	take up to 24 hours to be able to view or download the file. If you
	still can't access a file after 24 hours, contact your domain
	administrator. 

You may still be able to access the file from the browser:
%%%URLHERE

@carlmalamud
Copy link

I was chugging along nicely for a while, but I now am also getting same error as @grudloff. I was in fact able to pull the file up in a browser and start the download as indicated above. I looked in the gdown cookie and didn't see any download_warning lines, so evidently we never got the cookie back from them with the additional authorization.

(I have now installed 3.11.1, but was running on 3.11.0 before, I simply inserted a "rm ~/.cache/gdown/cookies.json" every fifty lines. Sorry, it was working so I didn't want to bother it. :). The upgrade doesn't seem to help on the above error.

@carlmalamud
Copy link

I am imagining that the error might have something to do with my being an authenticated user in the browser and not via gdown. I'm not sure is presenting an oauth token might make a difference here?

@wkentaro
Copy link
Owner

I'm not sure is presenting an oauth token might make a difference here?

I don't think so, gdown uses requests inside without using any browsers.

@kshitijagrwl
Copy link

kshitijagrwl commented Jul 6, 2020

Solved by disabling certificate verification by changing line 111 in download.py

res = sess.get(url, stream=True, verify=False)

However it does display this warning
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning

@wkentaro
Copy link
Owner

wkentaro commented Jul 6, 2020

Solved by disabling certificate verification

In my case, it didn't work.

@e96031413
Copy link

Older version gdown also helps.

pip install gdown==4.6.0

I finally solved this issue by using 4.6.0 gdown to download files.

@aasyedd1
Copy link

@e96031413 worked like a charm. thanks alot

@neeeal
Copy link

neeeal commented Jan 17, 2024

pip install gdown==4.6.0

actually solved my issue. thanks

@wkentaro wkentaro unpinned this issue Jan 20, 2024
@wkentaro
Copy link
Owner

This PR #300 should help this issue in some regard. I also added FAQ to the README.
https://github.com/wkentaro/gdown?tab=readme-ov-file#i-set-the-permission-anyone-with-link-but-still-cant-download

Releasing v5.0.0 soon.

@pmeier
Copy link
Contributor

pmeier commented Jan 29, 2024

When hitting large files that GDrive wants extra confirmation before it starts the download, e.g. https://drive.google.com/uc?id=1r6o0pSROcV1_VwT4oSjA2FBUSCWGuxLK, we currently hit this branch:

gdown/gdown/download.py

Lines 31 to 35 in ae122f4

m = re.search('id="download-form" action="(.+?)"', line)
if m:
url = m.groups()[0]
url = url.replace("&", "&")
break

The relevant corresponding HTML looks like

<form id="download-form" action="https://drive.usercontent.google.com/download" method="get">
	<input type="submit" id="uc-download-link" class="goog-inline-block jfk-button jfk-button-action" value="Download anyway"/>
	<input type="hidden" name="id" value="1r6o0pSROcV1_VwT4oSjA2FBUSCWGuxLK">
	<input type="hidden" name="confirm" value="t">
	<input type="hidden" name="uuid" value="ce320bab-e9f0-4d0d-a9d8-8cede0161915">
</form>

The branch above just extracts https://drive.usercontent.google.com/download from it and this later fails other checks as this doesn't provide a file.

What we should do here is to extract the other parts of the form as well and append them as query. So for this example https://drive.usercontent.google.com/download?id=1r6o0pSROcV1_VwT4oSjA2FBUSCWGuxLK&confirm=t&uuid=ce320bab-e9f0-4d0d-a9d8-8cede0161915. As you can see this link also includes confirm=t that multiple people in this thread have already mentioned. I'll send a PR to fix this.

@pmeier
Copy link
Contributor

pmeier commented Jan 29, 2024

@wkentaro see #308. Could you please have a look?

@wkentaro wkentaro reopened this Feb 1, 2024
@wkentaro
Copy link
Owner

wkentaro commented Feb 1, 2024

Hi everyone.

I've just merged #308 by @pmeier, which adds extra pattern to parse the url to download.

Since I've never seen that pattern, I suspect it is a regional issue (I'm accessing from Japan, @pmeier is accessing from Germany). But at least It should help people who have the same issue as him.

@vanloc1808
Copy link

@wkentaro Hi, I observed that only downgrading to 4.6.0 helps, new version does not help :(

@wkentaro
Copy link
Owner

Can you please give me an example url?

@vanloc1808
Copy link

@vanloc1808
Copy link

vanloc1808 commented Feb 24, 2024

I tried both

gdown --fuzzy 'https://drive.google.com/file/d/1NmGrEJ1uxrrBgf98UCU9SgpgsGEs3sLb/view?usp=drive_link'

and

gdown https://drive.google.com/uc?id=1NmGrEJ1uxrrBgf98UCU9SgpgsGEs3sLb

But it only works for me with gdown==4.6.0

@wkentaro
Copy link
Owner

@vanloc1808 It seems working for me with the latest.

image

Maybe the cookies file is not helping? If so remove it by rm ~/.cache/gdown/cookies.txt

@vanloc1808
Copy link

@wkentaro it works for me, thank you!

@Junyi42
Copy link

Junyi42 commented Mar 2, 2024

Older version gdown also helps.

pip install gdown==4.6.0

I finally solved this issue by using 4.6.0 gdown to download files.

Restarting the terminal after the downgrading works for me!

@AndrewLt
Copy link

AndrewLt commented Mar 7, 2024

I had a funny moment today. I got the same issue explained in the first message on the topic. The solution was to reinstall a several times version of gdown and finally install 5.1.0 ver to solve the problem. But this version had this issue when I started searching for the solution 😆

p.s. it is for colab

@julienboussard
Copy link

julienboussard commented Mar 8, 2024

I had a funny moment today. I got the same issue explained in the first message on the topic. The solution was to reinstall a several times version of gdown and finally install 5.1.0 ver to solve the problem. But this version had this issue when I started searching for the solution 😆

p.s. it is for colab

Yeah this happened to me as well several times (with different versions). I'm not sure why, but changing the version (sometimes to a newer one, sometimes to an older one) seem to work, but always with a different version. Maybe it clears something and allows gdown to download again? I usually try versions 4.6.0, 5.1.0, or the latest (pip install --upgrade gdown). I also remove cookies.txt, and I end up (randomly) with a version that works. Hope this helps

@ArianAmani
Copy link

I had a funny moment today. I got the same issue explained in the first message on the topic. The solution was to reinstall a several times version of gdown and finally install 5.1.0 ver to solve the problem. But this version had this issue when I started searching for the solution 😆

p.s. it is for colab

Weirdly this worked for me too. And I was using the default gdown (pip install gdown) on colab using gdown --id ID without a problem until just a few days ago. Thanks!

@ain-soph
Copy link

@wkentaro I'm still suffering this issue today. (gdown version 5.2.0)

I'm trying to download my own uploaded dataset (10G)
https://drive.google.com/uc?id=1vv73kAHiKb4KiL_oIH4DOWzUoaTeKzt_

And it raises the error

gdown https://drive.google.com/uc?id=1vv73kAHiKb4KiL_oIH4DOWzUoaTeKzt_


Failed to retrieve file url:

        Too many users have viewed or downloaded this file recently. Please
        try accessing the file again later. If the file you are trying to
        access is particularly large or is shared with many people, it may
        take up to 24 hours to be able to view or download the file. If you
        still can't access a file after 24 hours, contact your domain
        administrator.

You may still be able to access the file from the browser:

        https://drive.google.com/uc?id=1vv73kAHiKb4KiL_oIH4DOWzUoaTeKzt_

but Gdown can't. Please check connections and **permissions.**

@JiaHeng-DLUT 's workaround works for me (https://stackoverflow.com/questions/65312867/how-to-download-large-file-from-google-drive-from-terminal-gdown-doesnt-work)

@wkentaro
Copy link
Owner

wkentaro commented Jun 14, 2024

@ain-soph It works for me now, so looks like too many requests?

image

@JiaHeng-DLUT 's workaround works for me (https://stackoverflow.com/questions/65312867/how-to-download-large-file-from-google-drive-from-terminal-gdown-doesnt-work)

We can't do this because the scope of gdown is without logging in.

this is another workaround: https://github.com/wkentaro/gdown?tab=readme-ov-file#i-set-the-permission-anyone-with-link-but-i-still-cant-download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug for issue
Projects
None yet