> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting started

export const Comments = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-zinc-500/20 bg-zinc-50/50 dark:border-zinc-500/30 dark:bg-zinc-500/10" data-callout-type="comments">
      <div class="w-4">
        <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" aria-label="Comments">
            <path d="M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM280 400C266.7 400 256 410.7 256 424C256 437.3 266.7 448 280 448L360 448C373.3 448 384 437.3 384 424C384 410.7 373.3 400 360 400L352 400L352 312C352 298.7 341.3 288 328 288L280 288C266.7 288 256 298.7 256 312C256 325.3 266.7 336 280 336L304 336L304 400L280 400zM320 256C337.7 256 352 241.7 352 224C352 206.3 337.7 192 320 192C302.3 192 288 206.3 288 224C288 241.7 302.3 256 320 256z" />
        </svg>
      </div>
      <div class="text-sm prose min-w-0 w-full">
        {children}
      </div>
    </div>;
};

export const GCell = ({children, className}) => <div className={`grid-table-cell ${className || ""}`} role="cell">
    {children}
  </div>;

export const GTH = ({children, className}) => <div className={`grid-table-th ${className || ""}`} role="columnheader">
    {children}
  </div>;

export const GRow = ({children}) => <div className="grid-table-row" role="row">{children}</div>;

export const GBody = ({children}) => <div className="grid-table-body" role="rowgroup">{children}</div>;

export const GHead = ({children}) => <div className="grid-table-head" role="rowgroup">{children}</div>;

export const GTable = ({children, className, cols}) => <div className={`grid-table not-prose overflow-hidden rounded-2xl ${className || ""}`} style={{
  "--grid-table-cols": cols
}} role="table">
    {children}
  </div>;

`anaconda-auth` is a client library and CLI for authenticating with Anaconda APIs and securely storing API keys. This package provides centralized authentication for the Anaconda ecosystem.

## Installation

```bash theme={null}
conda install anaconda-auth
```

## Basic usage

### Log in to Anaconda

This command opens your browser to authenticate your Anaconda account. Once completed, an API key is stored securely in your `/.anaconda/keyring`.

```bash theme={null}
anaconda auth login
```

### Check authentication status

This command displays information about the currently signed-in user.

```bash theme={null}
anaconda auth whoami
```

### Display your API key

This command prints the API key for the signed-in user (useful for non-interactive environments).

```bash theme={null}
anaconda auth api-key
```

### Logout

This command removes the stored API key from your keyring.

```bash theme={null}
anaconda auth logout
```

## Configuration

Configuration comes from multiple sources. When the same setting appears in more than one place, the highest-priority source wins:

1. `ANACONDA_AUTH_*` environment variables (highest priority)
2. `.env` file in the current working directory
3. Site settings (`[sites.<NAME>]`) in `/.anaconda/config.toml`
4. Global plugin settings (`[plugin.auth]`) in `/.anaconda/config.toml`
5. Conda context (proxy servers, SSL settings) from `.condarc`

### Site configuration

Use `anaconda sites add` to register the Anaconda Platform domain you want to authenticate against:

```bash theme={null}
anaconda sites add --domain <FQDN> --default
```

<Comments>
  Replace \<FQDN> with the fully qualified domain name (FQDN) you want to authenticate against.
</Comments>

This writes a `[sites]` entry to `.anaconda/config.toml` and sets it as the default site. To verify, run `anaconda sites list`. For the full list of site management commands, see [sites](/docs/cli-reference/anaconda-auth/commands/sites).

<Note>
  If you are using anaconda.com, no site configuration is needed.
</Note>

All of the parameters in the table below can be set per-site in a `[sites.<name>]` section. When a parameter is not set on the site, the value from `[plugin.auth]` is used as a fallback. For more information on site configuration, see the [sites command reference](/docs/cli-reference/anaconda-auth/commands/sites).

### Global options

The `[plugin.auth]` section of `/.anaconda/config.toml` sets defaults that apply across all sites.

<Tip>
  Every parameter can also be set via an `ANACONDA_AUTH_` environment variable or a `.env` file.
</Tip>

<GTable cols="20% 30% 35% 15%">
  <GHead>
    <GRow>
      <GTH>Parameter</GTH>
      <GTH>Environment Variable</GTH>
      <GTH>Description</GTH>
      <GTH>Default</GTH>
    </GRow>
  </GHead>

  <GBody>
    <GRow>
      <GCell>`domain`</GCell>
      <GCell>`ANACONDA_AUTH_DOMAIN`</GCell>
      <GCell>Default domain when no site is configured. Use `anaconda sites add` to specify site.</GCell>
      <GCell>`anaconda.com`</GCell>
    </GRow>

    <GRow>
      <GCell>`ssl_verify`</GCell>
      <GCell>`ANACONDA_AUTH_SSL_VERIFY`</GCell>
      <GCell>Enable SSL verification for all requests</GCell>
      <GCell>`True`</GCell>
    </GRow>

    <GRow>
      <GCell>`api_key`</GCell>
      <GCell>`ANACONDA_AUTH_API_KEY`</GCell>
      <GCell>API key (overrides keyring lookup)</GCell>
      <GCell>`None`</GCell>
    </GRow>

    <GRow>
      <GCell>`preferred_token_storage`</GCell>
      <GCell>`ANACONDA_AUTH_PREFERRED_TOKEN_STORAGE`</GCell>
      <GCell>Where to store the login token. `anaconda-keyring` uses a file-based keyring at `/.anaconda/keyring`. `system` uses the OS keyring if available, falling back to `anaconda-keyring`.</GCell>
      <GCell>`anaconda-keyring`</GCell>
    </GRow>

    <GRow>
      <GCell>`extra_headers`</GCell>
      <GCell>`ANACONDA_AUTH_EXTRA_HEADERS`</GCell>
      <GCell>Extra request headers in JSON format</GCell>
      <GCell>`None`</GCell>
    </GRow>

    <GRow>
      <GCell>`use_device_flow`</GCell>
      <GCell>`ANACONDA_AUTH_USE_DEVICE_FLOW`</GCell>
      <GCell>Use the OAuth device code flow for login instead of a browser redirect</GCell>
      <GCell>`False`</GCell>
    </GRow>

    <GRow>
      <GCell>`use_unified_repo_api_key`</GCell>
      <GCell>`ANACONDA_AUTH_USE_UNIFIED_REPO_API_KEY`</GCell>
      <GCell>Use a unified API key for conda repository access instead of a separate repo token</GCell>
      <GCell>`False`</GCell>
    </GRow>

    <GRow>
      <GCell>`disable_conda_auto_config`</GCell>
      <GCell>`ANACONDA_AUTH_DISABLE_CONDA_AUTO_CONFIG`</GCell>
      <GCell>Disable automatic configuration of conda's `channel_settings` on login</GCell>
      <GCell>`False`</GCell>
    </GRow>
  </GBody>
</GTable>

### Example configuration

```toml theme={null}
# /.anaconda/config.toml
default_site = "my-platform"

[sites."my-platform"]
domain = "platform.example.com"
ssl_verify = false

[plugin.auth]
ssl_verify = true
preferred_token_storage = "anaconda-keyring"
```

In this example, SSL verification is disabled for the `my-platform` site but remains enabled as the default for any other site.

## Non-interactive usage

API keys issued by `anaconda auth login` are valid for one year. On systems without interactive browser access, there are several ways to authenticate:

<Tabs>
  <Tab title="Environment variable">
    1. On a system with browser access, run `anaconda auth api-key` to get your API key.
    2. On the non-interactive system, set the `ANACONDA_AUTH_API_KEY` environment variable (or add it to a `.env` file in your working directory).

    ```bash theme={null}
    export ANACONDA_AUTH_API_KEY=$(anaconda auth api-key)
    ```
  </Tab>

  <Tab title="Copy the keyring file">
    When `preferred_token_storage` is set to `anaconda-keyring` (the default), credentials are stored in `/.anaconda/keyring`. You can copy this file to another machine:

    1. On a system with browser access, run `anaconda auth login`.
    2. Copy `/.anaconda/keyring` to the same path on the target system.
  </Tab>

  <Tab title="Device flow">
    If the site supports it, configure the device code flow so that `login` displays a URL and code instead of opening a browser:

    ```bash theme={null}
    anaconda sites add --domain platform.example.com --use-device-flow --default
    anaconda auth login
    ```

    The CLI will print a verification URL and a one-time code. Open that URL on any device with a browser and enter the code. The login completes on the headless system.
  </Tab>
</Tabs>
