Google Drive API, Service Account - Exported HTML from Google Doc with Embedded Images Expiring

m-a
Bronze 2
Bronze 2

Hello Google Cloud Community,

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!

Solved Solved
0 2 542
1 ACCEPTED SOLUTION

I understand your question, and thanks for posing it so clearly and providing the sample code, too. 

Unfortunately I don't know the answer, and EVEN WORSE, I think you're in the wrong room, which means no-one else here is likely to know the answer you're seeking.  This forum is mostly focused on Apigee API management, and your question is about the Google Drive API and something related to expiry of exported content.  The good news is, I have a suggestion. For your question, I think you want to ask in the Workspace Developer forum, attach the label "APIs" to your question, and maybe specifically address your question to @wescpy .

Good luck!

View solution in original post

2 REPLIES 2

I understand your question, and thanks for posing it so clearly and providing the sample code, too. 

Unfortunately I don't know the answer, and EVEN WORSE, I think you're in the wrong room, which means no-one else here is likely to know the answer you're seeking.  This forum is mostly focused on Apigee API management, and your question is about the Google Drive API and something related to expiry of exported content.  The good news is, I have a suggestion. For your question, I think you want to ask in the Workspace Developer forum, attach the label "APIs" to your question, and maybe specifically address your question to @wescpy .

Good luck!

Dear dchiesa1,

Thank you for your guidance and for pointing out the correct forum to post my question. I apologize for the oversight - I'm still getting accustomed to navigating the different sections of this community.

I appreciate your help and your suggestion to reach out in the Workspace Developer forum. I will follow your advice and post my question there.

Once again, thank you for your support.

Best Regards,