Set up ADC for a cloud-based development environment

When you use a Google Cloud cloud-based development environment such as Cloud Shell or Cloud Code, the tool uses the credentials you provided when you signed in, and manages any authorizations required. You cannot use the gcloud CLI to configure ADC in these environments. If you need to use a different user account to configure ADC, or configure ADC using a service account, use a local development environment or a Google Cloud compute resource as your development environment.

In Cloud Workstations, you can provide credentials to ADC in one of the following ways:

  • Sign in using the Workstations UI: When you sign in to your workstation through the Google Cloud console, Cloud Workstations makes your user credentials available through the workstation's metadata server. Cloud Client Libraries, the gcloud CLI, and other tools that support ADC automatically retrieve these credentials from the metadata server without requiring a local credential file or the GOOGLE_APPLICATION_CREDENTIALS environment variable.

    Because ADC checks GOOGLE_APPLICATION_CREDENTIALS and local credential files before querying the metadata server, ensure neither is set if you want ADC to use your workstation sign-in credentials.

  • Authenticate manually: Run gcloud auth application-default login in your workstation terminal to generate a local ADC credential file.

What's next