When I read:
https://developers.google.com/drive/api/reference/rest/v3/revisions/list
and try this call right on the page - it works fine. I specify the following fields to retrieve:
fields='nextPageToken, revisions(id, modifiedTime, lastModifyingUser)'
But when I try to perform the same call with a Google Service Account credentials, it responds with a error:
HttpError: <HttpError 400 when requesting https://www.googleapis.com/drive/v3/files/1Exl8BrT_h0iG4qJ20InTyV_XZyeODF7OlfjI5JuBfa8/revisions?pag... returned "Invalid field selection emailAddress". Details: "[{'message': 'Invalid field selection emailAddress', 'domain': 'global', 'reason': 'invalidParameter', 'location': 'fields', 'locationType': 'parameter'}]">
Does anyone know how to fix this?
Update 1:
Strangely, it works if you change the fields to the following:
fields='nextPageToken, revisions(modifiedTime, lastModifyingUser(displayName, emailAddress))'
Omitting the `id`
Why Google Service Account fails to read the `id` of file revisions?
Hi @diovisgood,
Welcome to the Google Cloud Community!
It's possible that the Service Account lacks the necessary permissions to retrieve the id
. You can try giving the service account an owner role, then run the following code again.
fields='nextPageToken, revisions(id, modifiedTime, lastModifyingUser)'
(Note: Granting an Owner role to a service account is generally not recommended and should only be done here as a temporary measure for this test.)
I hope this helps. Thank you.