Skip to content

Instantly share code, notes, and snippets.

@tylertreat
Last active January 29, 2019 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylertreat/fb63b4f98ebcbdb88c787f2724b9fc6d to your computer and use it in GitHub Desktop.
Save tylertreat/fb63b4f98ebcbdb88c787f2724b9fc6d to your computer and use it in GitHub Desktop.
GCP OIDC proxy credentials signer
_adc_credentials, _ = google.auth.default(scopes=[IAM_SCOPE])
# For service accounts using the Compute Engine metadata service, which is the
# case for Cloud Function service accounts, service_account_email isn't
# available until refresh is called.
_adc_credentials.refresh(GRequest())
# Since the Compute Engine metadata service doesn't expose the service
# account key, we use the IAM signBlob API to sign instead. In order for this
# to work, the Cloud Function's service account needs the "Service Account
# Actor" role.
_signer = iam.Signer(
GRequest(), _adc_credentials, _adc_credentials.service_account_email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment