anaconda-auth
Theanaconda-auth package handles authentication across the Anaconda ecosystem. If you’re using Anaconda CLIs or APIs, you’ll use this package to log in, manage API keys, and configure secure access to Anaconda’s curated repositories.
This tool supports both command-line and Python interfaces, and stores credentials using system keyring or a dedicated file-based store.
Installing anaconda-auth
- Open Anaconda Prompt (Terminal on macOS/Linux).
-
Install
anaconda-authby running the following command:
If you already have
anaconda-auth installed, it’s best practice to update to the latest version from time to time:CLI usage
You’ll interact with the CLI usinganaconda auth and anaconda token commands:
anaconda auth commands
| Option | Description |
|---|---|
--version, -V | Show version and exit |
--help | Show help message |
| Command | Description | Arguments |
|---|---|---|
login | Open browser to authenticate with Anaconda | [anaconda.com, anaconda.org] [default: None] |
logout | Remove stored API key | |
whoami | Show the authenticated user | |
api-key | Print your current API key |
anaconda-auth also allows for authentication to Anaconda.org. If you do not include --at anaconda.com, you will be prompted to select a domain.anaconda token commands
| Option | Description |
|---|---|
--help | Show help message |
| Command | Description | Arguments |
|---|---|---|
install | Issue and set a new token | |
list | Show all installed tokens | |
config | Configure conda to use a token for private access | --force--no-forceDefault: no-force |
uninstall | Remove a token for a specific organization | --org <ORG_ID> |
Your
When you log in with
For more information on token storage, see Token Storage.
<ORG_ID> is part of your organization’s URL: https://anaconda.com/app/organizations/<ORG_ID>.When you log in with
anaconda-auth, a is stored in the specified storage location. This token is deleted when you log out. The auth token is valid for one year.For more information on token storage, see Token Storage.
Configuration
You can configureanaconda-auth by either:
- Setting parameters in the plugin.auth section of the
~/.anaconda/config.tomlfile. - Setting one or more
ANACONDA_AUTH_environment variables or using a.envfile in your working directory.
Setting variables in an
.env file in your working directory takes precedence over the ~/.anaconda/config.toml file.Configuration Parameters
| Config Key | Env Var | Description | Default |
|---|---|---|---|
domain | ANACONDA_AUTH_DOMAIN | Anaconda API domain | "anaconda.com" |
ssl_verify | ANACONDA_AUTH_SSL_VERIFY | Verify SSL certificates | true |
preferred_token_storage | ANACONDA_AUTH_PREFERRED_TOKEN_STORAGE | Token store: system or anaconda-keyring | "anaconda-keyring" |
api_key | ANACONDA_AUTH_API_KEY | Explicit API key if None, defaults to keyring storage | None |
extra_headers | ANACONDA_AUTH_EXTRA_HEADERS | Extra HTTP headers in JSON | None |
Example Config
Example Config
Using anaconda-auth in automated workflow environments
If you want to utilize Anaconda services as part of an automated workflow or CI/CD pipeline, you can use your API key to authenticate your conda client programmatically.
In the automated workflow system, set the API key using one of the following methods:
- Using the API key
- Using the keyring file
-
Retrieve your API key by running the following command:
-
On your automated workflow system, set the API key using one of the following methods:
- Environment Variable
- Config File
- Docker Container
Set theANACONDA_AUTH_API_KEYenvironment variable:
Python Usage
You can also useanaconda-auth in Python scripts and applications to authenticate your conda client programmatically.
login() does nothing. To override this behavior:
anaconda-auth to make API requests, see the official anaconda-auth docs on GitHub.
