Finding gcloud auth print-identity-token source code for Python

Where is the source code for gcloud ? I want to figure out what gcloud auth print-identity-token does so I can programatically do it from python, I don’t really want to just invoke gcloud auth print-identity-token - but I want to write code that can call a cloud function regardless of whether you are authed as a user or as service account

gcloud call this endpoint https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken

but for user, I don’t know as the api only accept service account

but that is for a service account

It looks like gcloud auth print-identity-token calls https://oauth2.googleapis.com/token - either way, I will just call the command :cry:

I think there’s an unofficial mirror https://github.com/google-cloud-sdk-unofficial/google-cloud-sdk|here?

you could also run the CLI with --log-http (or something like that) to view the API calls it’s making