Skip to content

ImpersonatedCredentials does not support external_account_authorized_user as a source credential, unlike other Google Auth libraries (nodeJs) #1843

@harbir-singh

Description

@harbir-singh

Description:

I am encountering a java.io.IOException when attempting to use impersonated credentials with a source credential type of external_account_authorized_user.

java.io.IOException: Error reading credential file from location /Users/.../.config/gcloud/application_default_credentials.json: A credential of type external_account_authorized_user is not supported as source credential for impersonation.
    at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentialsUnsynchronized(DefaultCredentialsProvider.java:183)

This limitation appears to be specific to the Java library. I have verified that the Node.js client does not have this same restriction and can successfully use this credential type for impersonation.

Reference:

The restriction seems to be enforced in ImpersonatedCredentials.java, which currently only allows UserCredentials or ServiceAccountCredentials as valid source types.

Expected Behavior:

The Java library should support external_account_authorized_user (and potentially other valid credential types) as a source for impersonation, consistent with other Google Cloud client libraries like Node.js.

Steps to Reproduce:

  1. Authenticate via gcloud using a method that generates an external_account_authorized_user type in the ADC file (e.g., certain federation or workforce identity scenarios).
  2. Attempt to initialize a Google Cloud Java client using ImpersonatedCredentials with this source credential.
  3. Observe the IOException.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions