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
such that the client_email is transposed to email and private_key is email,
so if you alter the code there above to to change the names, the client is authenticated properly.
Essentially, it seems somewhere in the codebase, the svc account's json field names are changed; the fix was to update jwtclient.js so that
client_email => email
private_key => key
fromJSON(json){console.log(json)if(!json){thrownewError('Must pass in a JSON object containing the service account auth settings.');}if(!json.email){thrownewError('The incoming JSON object does not contain a client_email field');}if(!json.key){thrownewError('The incoming JSON object does not contain a private_key field');}// Extract the relevant information from the json key file.this.email=json.email;this.key=json.key;this.keyId=json.private_key_id;this.projectId=json.project_id;this.quotaProjectId=json.quota_project_id;this.universeDomain=json.universe_domain||this.universeDomain;}
The text was updated successfully, but these errors were encountered:
I can confirm this is a bug - thank you for the full repro!
sofisl
added
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
size: s
Pull request size is small.
labels
Apr 18, 2025
Please make sure you have searched for information in the following guides.
A screenshot that you have tested with "Try this API".
N/A
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/jwtclient.ts#L311
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
A clear and concise description of what the bug is, and what you expected to happen.
JWTAccess tokens derived from service account keys as described here
seems to transpose or use incorrect json fields.
For example, if you initialize any of the clients
JWTAccess
orJWT
as shown in the repro section and run it, you'll initially seeThe JSON service account file definately has the
client_email
but it seems to get mismatched somewhere heresuch that the
client_email
is transposed toemail
andprivate_key
isemail
,so if you alter the code there above to to change the names, the client is authenticated properly.
Essentially, it seems somewhere in the codebase, the svc account's json field names are changed; the fix was to update
jwtclient.js
so thatclient_email
=>email
private_key
=>key
The text was updated successfully, but these errors were encountered: