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

Authentication issue when using images from Google drive #28

Open
rsmth opened this issue Feb 10, 2020 · 10 comments
Open

Authentication issue when using images from Google drive #28

rsmth opened this issue Feb 10, 2020 · 10 comments
Assignees
Labels

Comments

@rsmth
Copy link

rsmth commented Feb 10, 2020

The example from this blog post no longer runs. I get the following error:

Error in rgoogleslides::commit_to_slides(presentation_id, request) : Invalid requests[0].createImage: Access to the provided image was forbidden.

The file is successfully uploaded to Drive, but can't be moved from Drive to Slides.

Looks related to the API changes outlined here:
https://stackoverflow.com/questions/60076883/google-script-replaceallshapeswithimage-with-image-from-drive-doesnt-work-any-m/60085036#60085036

https://stackoverflow.com/questions/46029225/image-from-google-drive-to-google-slides-via-driveapp-getfilebyid

@hairizuanbinnoorazman
Copy link
Owner

Useful link for resolving this:
https://cloud.google.com/blog/products/application-development/upcoming-changes-to-the-google-drive-api-and-google-picker-api

Need to pick up the webcontent download link

@rsmth
Copy link
Author

rsmth commented Feb 12, 2020

Is switching from query parameter to HTTP header not a viable option? Seems like the more robust solution, but I know nothing

@hairizuanbinnoorazman
Copy link
Owner

hairizuanbinnoorazman commented Feb 12, 2020

Unfortunately, you can only pass a url to google slides api. Based on what I see in the documentation, I don't see it being possible to have the slides api add a header auth token while trying to get the image from drive. Let me experiment with the one proposed in the link i pasted above

Refer to the slides API documentation for more details regarding the image url to be passed in:
https://developers.google.com/slides/reference/rest/v1/presentations/request#CreateImageRequest

@rsmth
Copy link
Author

rsmth commented Feb 12, 2020

Got it. Thanks for taking a look

@hairizuanbinnoorazman
Copy link
Owner

Someone has already notified Google Engineers regarding this:
https://issuetracker.google.com/issues/148814758

Hopefully, the google engineers involved with this issue would introduce the required necessary fields in order to add the functionality back.

I will continue to monitor the changes on the issue and will adjust the package when the change in the API is ready

However, if you are unable to wait for such a fix and require a temporary workaround now, I would just the following:

Option 1:
Temporarily set the image to public and retrieve the public sharable url for it. Afterwards, immediately set the image to private

Option 2:
Set up a small nginx server and ftp images into the server. Instead of using the approach mentioned in this blog post: https://www.hairizuan.com/sending-ggplot-graphs-to-googleslides/, use the url of the image from the nginx server instead. (Just need to make sure that the rscript can access the images on the nginx server)

@hairizuanbinnoorazman hairizuanbinnoorazman changed the title Authentication issue Authentication issue when using images from Google drive Feb 12, 2020
@rsmth
Copy link
Author

rsmth commented Feb 12, 2020

Looks like they're also looking into the ability to accept headers in API requests https://partnerissuetracker.corp.google.com/issues/149385431

@hairizuanbinnoorazman
Copy link
Owner

I'm unable to access the link - probably the website is meant for Google Cloud Partners? If there is any update on the situation, just update the issue here => we can revisit and attempt to fix the issue in the future

@hairizuanbinnoorazman
Copy link
Owner

An alternative idea would be to upload the image temporarily to Google Cloud Storage; serve it with a temporary link and then delete the object from Google Cloud Storage

@hairizuanbinnoorazman
Copy link
Owner

Update on this issue - tried waiting for Google Cloud Next 2021 - to see if this will be fixed. It now seems unlikely.
Will think/work on a workaround around this.

@hairizuanbinnoorazman
Copy link
Owner

Refer to the following issue for a possible workaround to be added to the package:
#33

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

No branches or pull requests

2 participants