mirror of
https://github.com/imjasonh/gcloud-help
synced 2026-07-14 00:46:53 +00:00
125 lines
4.8 KiB
Bash
125 lines
4.8 KiB
Bash
NAME
|
|
gcloud auth login - authorize gcloud to access the Cloud Platform with
|
|
Google user credentials
|
|
|
|
SYNOPSIS
|
|
gcloud auth login [ACCOUNT] [--no-activate] [--brief] [--no-browser]
|
|
[--cred-file=CRED_FILE] [--enable-gdrive-access] [--force]
|
|
[--no-launch-browser] [--update-adc] [GCLOUD_WIDE_FLAG ...]
|
|
|
|
DESCRIPTION
|
|
Obtains access credentials for your user account via a web-based
|
|
authorization flow. When this command completes successfully, it sets the
|
|
active account in the current configuration to the account specified. If no
|
|
configuration exists, it creates a configuration named default.
|
|
|
|
If valid credentials for an account are already available from a prior
|
|
authorization, the account is set to active without rerunning the flow.
|
|
|
|
Use gcloud auth list to view credentialed accounts.
|
|
|
|
If you'd rather authorize without a web browser but still interact with the
|
|
command line, use the --no-browser flag. To authorize without a web browser
|
|
and non-interactively, create a service account with the appropriate scopes
|
|
using the Google Cloud Console (https://console.cloud.google.com) and use
|
|
gcloud auth activate-service-account with the corresponding JSON key file.
|
|
|
|
In addition to Google user credentials, authorization using workload
|
|
identity federation or service account keys is also supported.
|
|
|
|
For authorization with external accounts (workload identity pools) or
|
|
service accounts, the --cred-file flag must be specified with the path to
|
|
the workload identity credential configuration file or service account key
|
|
file (JSON). Login with workload identity federation is not yet supported
|
|
in other Google Cloud CLIs (e.g. gsutil and bq) and is only applicable to
|
|
gcloud commands. For more information on workload identity federation, see:
|
|
https://cloud.google.com/iam/docs/workload-identity-federation.
|
|
|
|
For more information on authorization and credential types, see:
|
|
https://cloud.google.com/sdk/docs/authorizing.
|
|
|
|
EXAMPLES
|
|
To obtain access credentials for your user account, run:
|
|
|
|
$ gcloud auth login
|
|
|
|
To obtain access credentials using workload identity federation, run:
|
|
|
|
$ gcloud auth login --cred-file=/path/to/workload/configuration/file
|
|
|
|
POSITIONAL ARGUMENTS
|
|
[ACCOUNT]
|
|
User account used for authorization.
|
|
|
|
FLAGS
|
|
--activate
|
|
Set the new account to active. Enabled by default, use --no-activate to
|
|
disable.
|
|
|
|
--brief
|
|
Minimal user output.
|
|
|
|
--no-browser
|
|
Use this flag to authenticate the gcloud CLI on a machine without a web
|
|
browser.
|
|
|
|
Run gcloud auth login --no-browser and follow these steps:
|
|
|
|
1. Copy the long command that begins with "gcloud auth login
|
|
--remote-bootstrap=".
|
|
|
|
2. Paste and run this command on the command line of a different,
|
|
trusted machine that has local installations of both a web browser and
|
|
the gcloud CLI tool version 372.0 or later.
|
|
|
|
3. Copy the long URL output from the machine with the web browser.
|
|
|
|
4. Paste the long URL back to the first machine under the prompt,
|
|
"Enter the output of the above command", and press Enter to complete
|
|
the authorization.
|
|
|
|
--cred-file=CRED_FILE
|
|
Path to the external account configuration file (workload identity
|
|
pool, generated by the Cloud Console or gcloud iam
|
|
workload-identity-pools create-cred-config) or service account
|
|
credential key file (JSON).
|
|
|
|
--enable-gdrive-access
|
|
Enable Google Drive access.
|
|
|
|
--force
|
|
Re-run the web authorization flow even if the given account has valid
|
|
credentials.
|
|
|
|
--launch-browser
|
|
(DEPRECATED) Launch a browser for authorization. If not enabled or if
|
|
it is not possible to launch a browser, prints a URL to standard output
|
|
to be copied.
|
|
|
|
The --[no-]launch-browser flags are deprecated and will be removed on
|
|
June 7th 2022 (Release 389.0.0). Use --no-browser to replace
|
|
--no-launch-browser. Enabled by default, use --no-launch-browser to
|
|
disable.
|
|
|
|
--update-adc
|
|
Write the obtained credentials to the well-known location for
|
|
Application Default Credentials (ADC). Run $ gcloud auth
|
|
application-default --help to learn more about ADC. Any credentials
|
|
previously generated by gcloud auth application-default login will be
|
|
overwritten.
|
|
|
|
GCLOUD WIDE FLAGS
|
|
These flags are available to all commands: --access-token-file, --account,
|
|
--billing-project, --configuration, --flags-file, --flatten, --format,
|
|
--help, --impersonate-service-account, --log-http, --project, --quiet,
|
|
--trace-token, --user-output-enabled, --verbosity.
|
|
|
|
Run $ gcloud help for details.
|
|
|
|
NOTES
|
|
These variants are also available:
|
|
|
|
$ gcloud alpha auth login
|
|
|
|
$ gcloud beta auth login
|
|
|