I created the code which get the member's information by Google Workspace Directory API. This code is executed everyday, and sometime I fece the error which is "oauth2: cannot fetch token: 401 Unauthorized"
.
Bad thing is that this error is happend only 1-2 times per month, and I cannnot reproduce by myself. I mean, if I re-execute the code after facing this error, it works well.
I paste full error message below:
"failed to get the members by email, email ="***@***": Get "https://admin.googleapis.com/admin/directory/v1/groups/***": oauth2: cannot fetch token: 401 Unauthorized
Response: {
"error": "unauthorized_client",
"error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."
}"
API is executed by using Service Account which has appropriate roles below:
- https://www.googleapis.com/auth/admin.directory.user.readonly
- https://www.googleapis.com/auth/admin.directory.group.member.readonly
- https://www.googleapis.com/auth/admin.directory.group.readonly
Is it only better solution to use exponential back off?
Thank you in advance.