Environment details
- OS type and version: MacOS 14.1 (23B74)
- Java version: 17.0.9 (Eclipse Adoptium 17.0.9+9)
- Version(s):
com.google.auth:google-auth-library-oauth2-http:1.22.0
com.google.cloud:google-cloud-storage:2.31.0
Steps to reproduce
- Instantiate a KMS client without credentials and without logging in using gcloud command
- Attempt to create a key
Code example
Stack trace
io.grpc.StatusRuntimeException: UNAVAILABLE: Credentials failed to obtain metadata
at io.grpc.Status.asRuntimeException(Status.java:537)
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:538)
at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
at com.google.api.gax.grpc.ChannelPool$ReleasingClientCall$1.onClose(ChannelPool.java:570)
at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.google.auth.oauth2.GoogleAuthException: com.google.api.client.http.HttpResponseException: 400 Bad Request
POST https://oauth2.googleapis.com/token
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
at com.google.auth.oauth2.GoogleAuthException.createWithTokenEndpointResponseException(GoogleAuthException.java:127)
at com.google.auth.oauth2.GoogleAuthException.createWithTokenEndpointResponseException(GoogleAuthException.java:143)
at com.google.auth.oauth2.UserCredentials.doRefreshAccessToken(UserCredentials.java:272)
at com.google.auth.oauth2.UserCredentials.refreshAccessToken(UserCredentials.java:177)
at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:269)
at com.google.auth.oauth2.OAuth2Credentials$1.call(OAuth2Credentials.java:266)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.google.auth.oauth2.OAuth2Credentials$RefreshTask.run(OAuth2Credentials.java:633)
... 3 more
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request
POST https://oauth2.googleapis.com/token
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
at com.google.auth.oauth2.UserCredentials.doRefreshAccessToken(UserCredentials.java:270)
... 8 more
Any additional information below
Seems like 'UNAUTHORIZED would be more appropriate here; some mention of the lack of credentials, instead of saying the credentials didn't work (implying they were supplied), would be helpful.
Additionally, the error seen here causes a retry loop eventually timing out. The original call blocks for quite some time until the client gives up retrying. It seems unlikely retrying makes sense for this sort of error.
Environment details
Steps to reproduce
Code example
// exampleStack trace
Any additional information below
Seems like 'UNAUTHORIZED would be more appropriate here; some mention of the lack of credentials, instead of saying the credentials didn't work (implying they were supplied), would be helpful.
Additionally, the error seen here causes a retry loop eventually timing out. The original call blocks for quite some time until the client gives up retrying. It seems unlikely retrying makes sense for this sort of error.