google-drive-apihttp-status-code-429

Google Drive returns 429 when using saved photo as src for <img> tag


Using an ASP.NET API, I upload photos to my Google Drive, make the photos public, and retrieve their IDs. I then use the following string to display the photo: $"https://drive.google.com/thumbnail?id={photo.Id}&sz=w1000"

When I navigate to this link in a browser, it always works as expected — I see the photo I uploaded. However, when I use this link as the src for an <img> tag, I sometimes get a 429 Too Many Requests response.enter image description here

I haven't been able to determine any pattern as to when this happens. It doesn't seem to matter if there's only one image on the page or several. The problem can appear and disappear at random.

Interestingly, I noticed that successful image requests first call one URL enter image description here and then another URL enter image description here , which eventually returns the image.

I have tried clearing the browser cache, removing browser extensions, and even using incognito mode, but none of this helped.


Solution

  • Add the referrerPolicy="no-referrer" property to the tag.

    For ex: <img src="img source" referrerPolicy="no-referrer"/>.