Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting access token for service account: 401 Unauthorized while calling refresh on Google Credentials #1561

Open
nusbahcodes opened this issue Oct 30, 2024 · 4 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@nusbahcodes
Copy link

nusbahcodes commented Oct 30, 2024

I am using a service account to access the google cloud features like Drive and Contact to save data through my app. I have suddenly started getting this for all users of some clients. Rest of them seem to be working fine.

"exception_class": "com.google.auth.oauth2.GoogleAuthException",
"exception_message": "Error getting access token for service account: 401 Unauthorized
POST https://accounts.google.com/o/oauth2/token, iss: XXXX.iam.gserviceaccount.com
...
Caused by: com.google.api.client.http.HttpResponseException: 401 Unauthorized
POST https://accounts.google.com/o/oauth2/token
    ... suppressed 3 lines
    ... 61 more

Was and still working fine for certain clients, failing for all users of the other client. What setting should I verify? Domain wide delegation is correct. Clients say they haven't changed any setting on their end.

@lqiu96
Copy link
Contributor

lqiu96 commented Nov 4, 2024

Hi @nusbahcodes, thanks for reporting this issue. Could we get some code snippets and dependency versions to help us debug this issue? Specifically the versions of the auth library and client libraries (drive + contact).

At first glance, the token endpoint seems odd. I was expecting https://oauth2.googleapis.com/token, but it may by due to an older version of the auth library.

@lqiu96 lqiu96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 4, 2024
@nusbahcodes
Copy link
Author

Lib versions:
google-auth-library-oauth2-http-1.23.0.jar
google-api-services-drive-v3-rev20221023-2.0.0.jar

@lqiu96
Copy link
Contributor

lqiu96 commented Nov 6, 2024

Thanks, but I would need some code snippets to figure out how you're using the library. Would you be able to share that to help with debugging?

@nusbahcodes
Copy link
Author

We have raised a support case for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants