# Sign-in commands

> Sign in, see who is signed in and what the sign-in may do, and sign out.

Source: https://rehearsal.dev/docs/reference/cli-sign-in

These commands sign the CLI in to your Rehearsal account and sign it out again. You approve a sign-in in your browser, and the CLI saves it on this computer for later commands. `rehearsal whoami` shows who is signed in, what the sign-in may do, and the workspace, project and app in use. [Install and sign in](https://rehearsal.dev/docs/cli/install.md) walks through your first sign-in.

## rehearsal login

Sign in to Rehearsal from this computer.

Rehearsal opens your browser, and you approve the sign-in there. Where nobody can use a browser, such as for a coding agent, add `--no-browser`.

What a sign-in may do comes in scopes. `--scope tunnel` connects apps on this computer, and `--scope testing:read` reads projects, tests and runs. `--scope testing:run` starts paid runs and explorations, and changes how your projects are set up. `--scope hosts` connects this computer to open the runs you start. You get all four unless you name scopes, and then only the ones you name.

Signing in again ends the earlier sign-in from this computer and any local connection it opened.

```sh
rehearsal login [flags]
```

| Flag | Description |
| --- | --- |
| `--scope <scope>` | A scope to ask for, in place of the default four. Repeat it for each one. One of `tunnel`, `testing:read`, `testing:run` or `hosts`. |
| `--no-browser` | Print the approval link instead of opening a browser. The command then waits for you to approve it. |

Needs a Rehearsal account.

Ctrl+C stops waiting. Nothing is saved.

> [!NOTE]
> This command has no JSON output, and it stops with an error when you pass `--json`. Signing in needs a person to approve it in a browser.

```sh
# Sign in
rehearsal login

# Sign in on a machine with no browser
rehearsal login --no-browser
```

## rehearsal whoami

Show who is signed in, what the sign-in may do, and what is in use here.

Shows the account, what this sign-in may do, the workspaces it reaches, and the workspace, project and app this folder uses, each with where it came from. With `--json` it also lists every operation and whether this sign-in may use it.

```sh
rehearsal whoami
```

Needs a saved sign-in.

```sh
# See who is signed in
rehearsal whoami

# Read it in a script
rehearsal whoami --json
```

## rehearsal logout

Sign out and remove the saved sign-in.

Rehearsal ends the sign-in, then deletes the file on this computer that held it.

```sh
rehearsal logout [flags]
```

| Flag | Description |
| --- | --- |
| `--dry-run` | Ask and check everything, then stop before anything starts or changes, and say what would happen. Off by default. |

```sh
# Sign out
rehearsal logout

# Sign out from a script
rehearsal logout --json

# See which sign-in it would end
rehearsal logout --dry-run
```
