2

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:

Is it only better solution to use exponential back off?
Thank you in advance.

y-kishi
  • 21
  • 2
  • Edit your question and include enough code to reproduce the problem. My guess is either you are creating tokens too often or the token has been invalidated. Without code, I can only guess. – John Hanley Aug 15 '22 at 09:08
  • Thank you for replying. And sorry, I cannot show that code due to some reasons (like client's contract issue). But I have an idea what you pointed out and I will check around these processes. – y-kishi Aug 18 '22 at 00:19

0 Answers0