3

I am using google drive to show images on a website. I'm using the following url to show the images:

https://drive.google.com/uc?export=view&id={fileId}

It works fine on most occasions, but some users don't see the images and get the following error message:

Failed to load resource: the server responded with a status of 403 ()

The image files and folders on the google drive are shared with everybody with a link to see. The problem does not seem browser related.

Anyone an idea how to fix this? Are there some things I forgot to do (do I need some kind of API key in the link)?

sboc
  • 31
  • 1
  • 2

3 Answers3

0

I've dealt with this problem working with Ionic Angular, in the lastest versions you should use https://lh3.google.com/u/0/d/{img-ID} as Edso said and it solves the problem. Consider that the images will only load if you have a logged google account, otherwhise the status of the response will be 302 and image will never load.

LookForAngular
  • 1,030
  • 8
  • 18
JuanFCVal
  • 1
  • 1
0

ok i know i am late... and my answer may not work for you but it did for me.

i was getting the 403 forbidden error when i used this link https://drive.google.com/uc?export=view&id={file-id}

the problem wasn't with the link. but with the file access. so, earlier when i viewed the file access it was like this
link with restricted access

and the response in html file was like this
403 forbidden error

but if i just click on restricted and change it to anyone, the html was able to fetch it and it worked.

link with public access

and then the html response was able to fetch it with a couple of redirects which were automatic
file was able to be fetched

make sure public access is set to viewer or anyone who knows how to open devtools will be able to comment or edit your file.

also i have shared original link as i have already deleted the file on that link before publishing this answer.

-1

As of today I have the same issue. (just like a few months back when Google ended the classic sites, which I (mis)used as an image repository.)

After I cleared all cookies from the browser, the images were visible again. So that solved this problem.

If your problem persists, you should change the URL.

This URL gives a 403 err:

https://drive.google.com/uc?export=view&id={img-ID}

Change that to:

https://lh3.google.com/u/0/d/{img-ID}

For example: setting a favicon in a WebApp:

return template.evaluate()
  .setFaviconUrl('https://lh3.google.com/u/0/d/1qMrq5o54jhg5jedu9fLtzUG4dF1ijKZT1#.ico')
Edzo
  • 1
  • 3