- gcloud auth print-access-token - print an access token for the specified account
Print an access token for the specified account. See RFC6749 for more information
about access tokens.
Note that token itself may not be enough to access some services. If you use the token with curl or similar tools, you may see permission errors similar to "API has not been used in project 32555940559 before or it is disabled.". If it happens, you may need to provide a quota project in the "X-Goog-User-Project" header. For example,
curl -H "X-Goog-User-Project: your-project" -H "Authorization: Bearer $(gcloud auth print-access-token)" foo.googleapis.com
The identity that granted the token must have the serviceusage.services.use permission on the provided project. See https://cloud.google.com/apis/docs/system-parameters for more information.
To print access tokens:
gcloud auth print-access-token
- POSITIONAL ARGUMENTS
- Account to get the access token for. If not specified, the current active account will be used.
- GCLOUD WIDE FLAGS
These flags are available to all commands:
$ gcloud helpfor details.
- These variants are also available:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-06-29 UTC.