The Colab CLI supports two authentication strategies to interact with the Colab backend, selectable via the global --auth=<provider> flag. This determines how the CLI obtains credentials for the colab.research.google.com host.
1. oauth2 (Default)
Uses a remote copy-paste flow designed for local, remote, headless, or container environments.
- How it works: The CLI prints an authorization URL. You sign in via your browser, copy the authorization code displayed by Google, and paste it back into the CLI prompt.
- Storage: The refresh token is cached at
~/.config/colab-cli/token.json. - Note: If you have old cached tokens from before the remote flow update, you must delete
~/.config/colab-cli/token.json to trigger a fresh consent flow.
2. adc (Application Default Credentials)
Uses the standard Google discovery chain via google.auth.default(). This is ideal if you are running the CLI in an environment that already has ambient Google credentials (e.g., via GOOGLE_APPLICATION_CREDENTIALS, gcloud auth application-default login, or GCE/GKE metadata servers).
Important for adc users: If using gcloud auth application-default login, you must explicitly include the required scopes, otherwise the CLI will fail. Use the following command to re-authenticate with the necessary scopes:
gcloud auth application-default login \
--scopes=openid,\nhttps://www.googleapis.com/auth/cloud-platform,\nhttps://www.googleapis.com/auth/userinfo.email,\nhttps://www.googleapis.com/auth/colaboratory