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

# magnet login

> Log in to Magnet from the command line using the browser device flow.

The `magnet login` command authenticates the CLI as your Magnet user. It opens your browser to a confirmation page, and once you approve the displayed code, stores a personal CLI token on your machine (in `~/.magnet/auth.json`, scoped to the API base URL).

## Usage

```bash theme={null}
magnet login
```

```text theme={null}
  Confirm code 4JLC-LPQ6 to log in.

  Opening https://www.magnet.run/cli/verify?code=4JLC-LPQ6 ...
Logged in as you@example.com
```

If the browser can't be opened (for example over SSH), the CLI prints the verification URL and code so you can complete the approval from any device.

## Options

| Option            | Description                                                        |
| ----------------- | ------------------------------------------------------------------ |
| `--token <token>` | Use an existing CLI token instead of the browser flow.             |
| `--no-browser`    | Don't open a browser; print the verification URL and code instead. |

## Examples

Log in on a headless machine:

```bash theme={null}
magnet login --no-browser
```

Reuse a token issued elsewhere (for example, provisioning a container):

```bash theme={null}
magnet login --token mgcli_xxxxxxxx
```

## Related

* [`magnet whoami`](/cli/whoami) — check who you're logged in as
* [`magnet logout`](/cli/logout) — revoke the stored token
* Tokens can also be reviewed and revoked from your Magnet account settings.
