0

Invalid requests[0].replaceImage: Access to the provided image was forbidden

I am uploading an image in the drive and trying to add it to slides using the python APIs.

Since the image needs to be publicly accessible, I am doing the following:

after upload, I am changing the permission of the image to "anyoneWithLink".

After that I try to use the link to this image in "createImage" request.

If I use the secure URL for this as shown in create image tutorial using below code,

drive_service.files().get_media(fileId=imageId).uri

I get error : "Access to the provided image was forbidden."

I get the same error if I use webContentLink, retrieved as below:

drive_service.files().get(fileId=imageId, fields="webContentLink")

If I use webViewLink instead, I get a different error as follows: "There was a problem retrieving the image. The provided image should be publicly accessible, within size limit, and in supported formats."

As I mentioned earlier, the image is already made public by changing the permissions. Are there any other steps I need to do for this to work? Also, which link should I use as url in the createImage request?

The image is 16kb png file.

  • This is a bug in Google API, please check linked question and answer. It includes link to mentioned bug – Kos Jan 28 '22 at 22:32
  • 1
    Does this answer your question? [Google slides API replaceAllShapesWithImage returns error for Google Drive file (2020)](https://stackoverflow.com/questions/62591615/google-slides-api-replaceallshapeswithimage-returns-error-for-google-drive-file) – Kos Jan 28 '22 at 22:32
  • I have seen the bug. but the API "replaceAllShapesWithImage" seems to work sometimes randomly. That is not what I am facing. The createImage request throws an error every single time I have tried, so wasn't sure if the issues are related – Renuka Dixit Jan 31 '22 at 13:14
  • well, a) it's image from Google Drive b) it's public image c) it used in Slides API and d) it gets access forbidden error. I think it's enough to say this is somehow similar issue, isn't it? – Kos Jan 31 '22 at 14:00

0 Answers0