Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinHsieh committed Aug 24, 2023
1 parent 99831c6 commit 0f86c0b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sharely/share_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 0f86c0b

Please sign in to comment.