From 0f86c0bcd3fe119dbac1e66a0789af057fbeabff Mon Sep 17 00:00:00 2001 From: RobinHsieh Date: Thu, 24 Aug 2023 16:24:24 +0800 Subject: [PATCH] update --- Sharely/share_file.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sharely/share_file.py b/Sharely/share_file.py index 3b56a7c..e7793b0 100644 --- a/Sharely/share_file.py +++ b/Sharely/share_file.py @@ -60,6 +60,7 @@ def callback(request_id, response, exception): # See availability about setting an expiration date for file access in: # https://workspaceupdates.googleblog.com/2022/10/expiring-access-controls-google-drive.html + # https://stackoverflow.com/questions/75423531/google-service-account-drive-api-unable-to-set-expirationtime-python user_permission = {'type': 'user', 'role': 'reader', 'emailAddress': real_user @@ -86,6 +87,16 @@ def callback(request_id, response, exception): body=user_permission, fields='id',)) + user_permission = {'type': 'user', + 'role': 'reader', + "expirationTime": f"{expire_date_utc8.strftime('%Y-%m-%d')}T23:59:59+08:00:00", + 'emailAddress': real_user + } + + batch.add(service.permissions().update(fileId=file_id, + body=user_permission, + fields='id',)) + batch.execute() except HttpError as error: