You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[google-auth-library-java] Generating ID token with ImpersonatedCredentials does not support overriding quota project #12604
Is your feature request related to a problem? Please describe. ImpersonatedCredentials accepts a quota project in its builder, and the quota project is properly overridden when generating an access token. However, when generating id token with the idTokenWithAudience() method, it won't perform such override. The impact is that if a service does impersonate many IdTokens on its own quota - it exceeds a default limit of 60k.
Describe the solution you'd like
It seems to me that providing the quota project in the additionalFields argument when invoking the IamUtils.getIdToken() method would work
Describe alternatives you've considered
There doesn't seem to be good alternatives.
changed the title [-]Generating ID token with ImpersonatedCredentials does not support overriding quota project[/-][+][google-auth-library-java] Generating ID token with ImpersonatedCredentials does not support overriding quota project[/+]on Apr 1, 2026
Quota Project Id is set via the x-goog-user-project header. generateIdToken is called using sourceCredentials, to use a different quota project ID for the generateIdToken RPC and I believe you would need to set the quota project ID on sourceCredentials (e.g. sourceCredentials.createWithQuotaProject(...)), not on ImpersonatedCredentials itself. The quotaProjectId on ImpersonatedCredential is used for downstream API requests made as the impersonated principal.
As I understand, the flow for idTokenWithAudience is:
IamUtils.getIdToken is called with sourceCredentials
Builds a request with sourceCredentials: HttpCredentialsAdapter adapter = new HttpCredentialsAdapter(credentials);
The x-goog-user-project header for the quotaProjectId on sourceCredentials will be populated if it exists
This looks to be working as intended, but it may not be super clear (please let me know if you observed anything otherwise). I will update the javadocs to make this clearer.
Activity
TimurSadykov commentedon Aug 30, 2023
@sai-sunder-s what do you think?
ABHISHEK0S1INGH commentedon Nov 2, 2025
Can You please assign this is me?
[-]Generating ID token with ImpersonatedCredentials does not support overriding quota project[/-][+][google-auth-library-java] Generating ID token with ImpersonatedCredentials does not support overriding quota project[/+]lqiu96 commentedon Oct 7, 2026
Apologies, this slipped from our backlog. I took a quick look at this.
The
generateIdTokenendpoint itself doesn't take in aquotaProjectIdfield in the request body (and IIUC, passing it viaadditionalFieldswould not work): https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdTokenQuota Project Id is set via the
x-goog-user-projectheader.generateIdTokenis called usingsourceCredentials, to use a different quota project ID for thegenerateIdTokenRPC and I believe you would need to set the quota project ID onsourceCredentials(e.g.sourceCredentials.createWithQuotaProject(...)), not onImpersonatedCredentialsitself. ThequotaProjectIdon ImpersonatedCredential is used for downstream API requests made as the impersonated principal.As I understand, the flow for
idTokenWithAudienceis:IamUtils.getIdTokenis called withsourceCredentialssourceCredentials:HttpCredentialsAdapter adapter = new HttpCredentialsAdapter(credentials);x-goog-user-projectheader for thequotaProjectIdonsourceCredentialswill be populated if it existsThis looks to be working as intended, but it may not be super clear (please let me know if you observed anything otherwise). I will update the javadocs to make this clearer.
docs(auth): clarify quota project behavior on ImpersonatedCredentials (…