Dear @wescpy,
I was referred to you by @dchiesa1 in relation to a technical issue I'm currently facing with the Google Drive API. I apologize for contacting you directly.
I am currently working with the Google Drive API to export documents as HTML via a service account. I noticed that the images attached to these documents are hosted under googleusercontent.com. However, these links seem to expire after some time.
Previously, I was using OAuth authentication for the export, and there were no expirations for these image links (some are still accessible even after 3 years).
I am interested in making the image links from the service account export have the same permanency as those from the OAuth authentication. Is there a way to explicitly set these image links to have no expiration time, or to at least significantly extend their lifetime? And if so, is it possible to set this via code?
Here is a simplified version of the code I am using:
require 'google/apis/drive_v3' require 'stringio' authorization = GoogleServiceAccountAuthorization.new().authorization google_drive_service = Google::Apis::DriveV3::DriveService.new google_drive_service.authorization = authorization file = google_drive_service.get_file(docs_id, fields: '*', supports_all_drives: true) export_link = file.export_links['text/html'] google_drive_service.http(:get, export_link)
Any insights or suggestions would be greatly appreciated. Thank you!
I'm not familiar with this behavior. How long before the images "expire?" Why not change your code back to OAuth client IDs? Another idea to try: give the service account access to the document before you export it to HTML and see whether that helps or not. For you and other developers trying to use Google APIs like Drive (and others from Workspace) as well as other Google APIs from GCP, Maps, etc., I'm putting together various blog posts on this topic, so feel free to check it out if interested.