Skip to content

Instantly share code, notes, and snippets.

@mattes
Created September 10, 2020 23:21
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 mattes/3326768f5a7fb7185415d9a010261954 to your computer and use it in GitHub Desktop.
Save mattes/3326768f5a7fb7185415d9a010261954 to your computer and use it in GitHub Desktop.
Get access token via curl for default service account on Google Cloud Compute Engine
METADATA=http://metadata.google.internal/computeMetadata/v1
SVC_ACCT=$METADATA/instance/service-accounts/default
ACCESS_TOKEN=$(curl -H 'Metadata-Flavor: Google' $SVC_ACCT/token | cut -d'"' -f 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment