# swb whoami

Who the control plane says you are, and the tenant every other command
operates in.

## Synopsis

```
usage: swb whoami [--json]
```

## Arguments and flags

| Flag | Takes | Default |
|---|---|---|
| `--json` | Nothing. Prints the record as the API answered it instead of the aligned lines. | off |
| `--help`, `-h` | Prints the command's help and exits. | off |

## What it prints

The console it is signed in to, then the answer's fields, one per line:

| Line | What it is |
|---|---|
| `console` | The console origin `swb login` signed in at. |
| `subject` | The caller's subject, as the token carries it. |
| `kind` | The kind of caller the control plane classified. |
| `tenant` | The tenant every other command operates in. `-` when the caller is in none. |
| `tenants` | Every tenant the person holds a role on. |
| `roles` | The roles the token carries. |
| `permissions` | The permission keys the token carries. |

`--json` prints `Query.me` as the API answered it: `kind`, `subject`,
`tenant`, `tenants`, `permissions`, `roles`, `features`. (`features` is in the
record and not in the lines.)

## The operation and the permission

`Query.me`. It names no permission: any signed-in caller may ask who they
are. What that caller may then read or write is decided per operation — every
other read needs `swb.apps.read` on the tenant.

## The same act in the console

The account menu in the console's top bar, and the tenant shown beside it.

## Refusals and exit status

Exit status is 0 on success and 1 on a refusal.

| Refusal | When |
|---|---|
| `not signed in or token expired — run swb login` | There is no credential file, or the access token expired with no refresh token. |
| `the control plane knows <subject> but places them in no tenant — the account is not bound to a tenant row` | The person signed in, but their account is bound to no tenant. |

## Example

```console
$ swb whoami
console      https://console.switchboard.example
subject      auth0|6f0c…
kind         person
tenant       willdan-energy
tenants      willdan-energy, willdan-water
roles        Switchboard/Operator
permissions  swb.apps.read, swb.deploys.run
```
