> ## 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

<div id="overview">
  # Overview
</div>

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.

<div id="interactive-login">
  # Interactive Sign in
</div>

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

```shell theme={null}
# Start Qoder CLI in the terminal
qodercli

# 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

If your environment does not support automatically opening a browser (e.g., remote servers or containers), set the `NO_BROWSER=true` environment variable. Qoder CLI will then print the sign-in URL for you to manually copy and open in a browser:

```shell theme={null}
export NO_BROWSER=true
qodercli
```

## 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.

<div id="pat">
  # Using a Personal Access Token
</div>

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 theme={null}
# Linux / macOS example
export QODER_PERSONAL_ACCESS_TOKEN="your_personal_access_token_here"
```

```shell theme={null}
# 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 theme={null}
# 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 valid tokens are set both via the `/login` command and this environment variable, the token provided by `/login` takes precedence.

<div id="env-vars">
  # Authentication-Related Environment Variables
</div>

| 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`.                                      |
| `NO_BROWSER`                  | Prevents the browser from opening automatically and prints the sign-in URL instead when set. |

<div id="check-status">
  # Checking Authentication Status
</div>

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.

<div id="logout">
  # Sign out
</div>

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

```shell theme={null}
# 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.

<div id="troubleshooting">
  # Troubleshooting
</div>

* **Browser did not open automatically**: Set `NO_BROWSER=true` and manually visit the printed URL.
* **Sign-in callback failed or timed out**: Ensure your local network can access Qoder services. Check your proxy settings if necessary. See Network and Proxy.
* **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.
