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

# Authentication

> Sign in with device authorization, inspect the session, and log out safely.

Wrapper uses Better Auth device authorization. The CLI prints a verification
URL, you press Enter to open it, approve a short code, and the CLI stores a
session token locally. The iOS viewer uses the same approval page with the
code already in the URL.

## Sign in

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

1. The CLI prints a verification URL and user code.
2. Press Enter to open the URL in your browser, or copy it if you are on a
   headless session.
3. Sign in with your Wrapper account and approve the device.
4. The CLI stores credentials and can mint short-lived Convex JWTs for backend
   calls.

While waiting for approval, the CLI may report `authorization_pending`. Leave
the command running until you approve or deny the request.

Optional flags for advanced setups:

```bash theme={null}
wrapper auth login --client-id <id> --scope <scope>
```

## Inspect and log out

```bash theme={null}
wrapper auth whoami
wrapper auth logout
```

Run `wrapper auth logout` on any device whose credentials may be exposed.

## Where credentials live

| Environment | Config directory | Auth file |
| - | - | - |
| Production (`NODE_ENV` unset) | `~/.config/wrapper/` | `auth.json` |
| Development (`NODE_ENV=development`) | `~/.config/wrapper-dev/` | `auth.json` |

Related state:

| Path | Contents |
| - | - |
| `~/.config/wrapper/config.json` | Optional prefix and other settings |
| `~/.local/state/wrapper/sessions.json` | Live local session registry (prod) |
| `~/.local/state/wrapper-dev/sessions.json` | Live local session registry (dev) |

Directories use restrictive permissions. Session tokens are redacted from logs.

## Why auth matters for attach

Local attach uses the loopback token in the session registry. It does not
require Convex or a Wrapper account. Remote share always requires auth, plus
Pro for the relay entitlement. See [Pricing](https://docs.wrapper.sh/reference/pricing.md).

Development builds with `NODE_ENV=development` and no Convex URL can exercise
host wrapping without a backend, but that is not the shipped binary path.

## Auth origin

Device approval runs on the web origin from `WRAPPER_AUTH_ORIGIN`:

| Mode | Default |
| - | - |
| Production | `https://wrapper.sh` |
| Development | `http://localhost:3000` |

See [Environment](https://docs.wrapper.sh/configuration/environment.md) for overrides.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.