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

# Sign-in and Authentication

## Overview

Authentication is required before using Qoder. When you run a command for the first time, Qoder CLI will automatically prompt you to sign in.

Qoder CLI uses Qoder's proprietary authentication system, which primarily offers two authentication methods:

- **Interactive Sign in (Recommended)**: Sign in via a browser or by pasting a token in the terminal. Ideal for daily local use.
- **Environment Variable**: Authenticate using a Personal Access Token. Suitable for CI/CD pipelines and headless automation environments.

## Interactive Sign in

Launch Qoder CLI in the terminal, then enter `/login` at the interactive prompt:

```shell
# Start Qoder CLI in the terminal
qoder

# At the interactive prompt, enter /login
/login
```

Then, select your preferred sign-in method:

- **Login with Qoder Platform (Browser)**: Opens a browser window to authenticate using your Qoder account.
- **Use Qoder Personal Access Token (QODER\_PERSONAL\_ACCESS\_TOKEN)**: Sets the `QODER_PERSONAL_ACCESS_TOKEN` environment variable using a token generated in your Qoder settings.

After making your selection, Qoder CLI will guide you through the remaining steps.

> `/login` You can also use the alias `/signin`.

### When the Browser Cannot Be Opened Automatically

In environments without a graphical interface, Qoder CLI automatically skips launching the browser, and the sign-in screen prints the sign-in URL directly—manually copy it into a browser to complete authentication. An environment is treated as having no graphical interface if any of the following conditions is met:

- `CI` is set;
- `BROWSER=www-browser`;
- `DEBIAN_FRONTEND=noninteractive`;
- inside an SSH session (`SSH_CONNECTION`);
- on Linux with none of `DISPLAY`, `WAYLAND_DISPLAY`, or `MIR_SOCKET` set.

Therefore, no extra configuration is needed on remote servers, in containers, or in CI environments. If the browser fails to open, you can likewise manually copy the URL printed on the screen.

### Automatic Token Refresh

After signing in via the browser, Qoder CLI automatically refreshes the token in the background, so you don't need to manually sign in again for daily use.

## Using a Personal Access Token

For non-interactive sessions or automated environments (such as CI/CD pipelines), you can authenticate using a Personal Access Token (PAT).

### Obtaining a Token

Create and manage your Personal Access Token on the following page:

> [https://qoder.com/account/integrations](https://qoder.com/account/integrations)

### Authenticating via Environment Variables

Set the token in the `QODER_PERSONAL_ACCESS_TOKEN` environment variable:

```shell
# Linux / macOS example
export QODER_PERSONAL_ACCESS_TOKEN="your_personal_access_token_here"
```

```shell
# Windows example (Command Prompt). Do not use quotes, as CMD will include them in the variable value
set QODER_PERSONAL_ACCESS_TOKEN=your_personal_access_token_here
```

```shell
# Windows example (PowerShell)
$env:QODER_PERSONAL_ACCESS_TOKEN="your_personal_access_token_here"
```

Once set, Qoder CLI will automatically use the PAT for authentication.

> If you have both set the `QODER_PERSONAL_ACCESS_TOKEN` environment variable and signed in via `/login`, authentication **uses the PAT from the environment variable first**; to use the credentials saved by `/login`, you must clear this environment variable first.

## Authentication-Related Environment Variables

| Environment Variable          | Description                                                            |
| :---------------------------- | :--------------------------------------------------------------------- |
| `QODER_PERSONAL_ACCESS_TOKEN` | Personal Access Token. Automatically uses PAT authentication when set. |
| `QODER_CONFIG_DIR`            | Custom configuration directory. Defaults to `~/.qoder`.                |

## Checking Authentication Status

Enter `/status` in an interactive session to open the status panel, which includes two tabs: Usage and Status. The Usage tab displays the API quota and token usage for the current session (plan type, quota usage, session duration, total code changes, etc.), while the Status tab shows the current CLI status information. This is the most direct entry point for troubleshooting if you suspect an authentication issue.

## Sign out

When you need to sign out of Qoder, enter `/logout` at the interactive prompt:

```shell
# At the interactive prompt, enter /logout
/logout
```

> `/logout` You can also use the alias `/signout`, which will prompt for confirmation before signing out.

If you authenticated using the `QODER_PERSONAL_ACCESS_TOKEN` environment variable, you must clear this environment variable before running `/logout`. Otherwise, the next startup will automatically sign in using that token again.

## Troubleshooting

- **Browser did not open automatically**: In environments without a graphical interface, Qoder CLI automatically skips launching the browser; manually copy the URL printed on the sign-in screen and open it in a browser.
- **Sign-in callback failed or timed out**: Ensure your local network can access Qoder services. Check your proxy settings if necessary. See [Network, Proxy, and VPC](/cli/network).
- **PAT is invalid or expired**: Go to the account integration page to regenerate the token and update `QODER_PERSONAL_ACCESS_TOKEN`.

For more troubleshooting steps, see [Sign-in and Authentication Issues](/cli/troubleshoot-auth).
