gcloud beta auth activate-service-account Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud beta auth activate-service-account - authorize access to Google Cloud with a service account
- SYNOPSIS
gcloud beta auth activate-service-account[ACCOUNT]--key-file=KEY_FILE[--password-file=PASSWORD_FILE|--prompt-for-password][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(BETA)To allowgcloud(and other tools in Google CloudCLI) to use service account credentials to make requests, use this command toimport these credentials from a file that contains a private authorization key,and activate them for use ingcloud. gcloud beta authactivate-service-account serves the same function asgcloud auth loginbut uses aservice account rather than Google user credentials.For more information on authorization and credential types, see:https://cloud.google.com/sdk/docs/authorizing.
Key FileTo obtain the key file for this command, use either theGoogle Cloud Console or
gcloudiam service-accounts keys create. The key file can be .json (preferred)or .p12 (legacy) format. In the case of legacy .p12 files, a separate passwordmight be required and is displayed in the Console when you create the key.CredentialsCredentials will also be activated (similar to running
gcloud config setaccount [ACCOUNT_NAME]).If a project is specified using the
--projectflag, the project isset in active configuration, which is the same as runninggcloud configset project [PROJECT_NAME]. Any previously active credentials, will beretained (though no longer default) and can be displayed by runninggcloud auth list.If you want to delete previous credentials, see
gcloud auth revoke.Note:Service accounts use client quotas for trackingusage.- EXAMPLES
- To authorize
gcloudto accessGoogle Cloud using an existing service account while also specifying a project,run:gcloudbetaauthactivate-service-accountSERVICE_ACCOUNT@DOMAIN.COM--key-file=/path/key.json--project=PROJECT_ID - POSITIONAL ARGUMENTS
- [
ACCOUNT] - E-mail address of the service account.
- [
- REQUIRED FLAGS
--key-file=KEY_FILE- Path to the private key file.
- OPTIONAL FLAGS
- At most one of these can be specified:
--password-file=PASSWORD_FILE- Path to a file containing the password for the service account private key (onlyfor a .p12 file).
--prompt-for-password- Prompt for the password for the service account private key (only for a .p12file).
- At most one of these can be specified:
- 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 helpfor details. - NOTES
- This command is currently in beta and might change without notice. Thesevariants are also available:
gcloudauthactivate-service-accountgcloudalphaauthactivate-service-account
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.