Google 驱动器映像出现 403 禁止错误

sbo*_*boc 5 image http-status-code-403 google-drive-api

我正在使用谷歌驱动器在网站上显示图像。我使用以下网址来显示图像:

https://drive.google.com/uc?export=view&id={fileId}
Run Code Online (Sandbox Code Playgroud)

它在大多数情况下工作正常,但有些用户看不到图像并收到以下错误消息:

Failed to load resource: the server responded with a status of 403 ()
Run Code Online (Sandbox Code Playgroud)

谷歌驱动器上的图像文件和文件夹与每个人共享,并有一个链接可供查看。该问题似乎与浏览器无关。

有人知道如何解决这个问题吗?是否有一些我忘记做的事情(我是否需要链接中的某种 API 密钥)?

Edz*_*dzo 4

截至今天,我有同样的问题。(就像几个月前谷歌结束了经典网站一样,我(错误地)将其用作图像存储库。)

当我清除浏览器中的所有 cookie 后,图像再次可见。这样就解决了这个问题。

如果问题仍然存在,您应该更改 URL。

此 URL 给出 403 错误:

https://drive.google.com/uc?export=view&id={img-ID}
Run Code Online (Sandbox Code Playgroud)

将其更改为:

https://lh3.google.com/u/0/d/{img-ID}
Run Code Online (Sandbox Code Playgroud)

例如:在 WebApp 中设置图标:

return template.evaluate()
  .setFaviconUrl('https://lh3.google.com/u/0/d/1qMrq5o54jhg5jedu9fLtzUG4dF1ijKZT1#.ico')
Run Code Online (Sandbox Code Playgroud)