# Signing in the CLI

Source: https://blocklive.io/docs/developers/cli/sign-in

How `blocklive login` works, what you choose when you approve it, how long a
sign-in lasts, and where it's kept.

## Before you start

-   A Blocklive account with a role at a team, an event or an organization.
-   Two-step verification on that account: an authenticator app or a security
    key. Turn it on at
    [blocklive.io/account/security](https://blocklive.io/account/security); see
    [two-step verification](https://blocklive.io/docs/account/sign-in#two-step-verification).
-   The CLI installed (see [install](https://blocklive.io/docs/developers/cli#install)).

## Sign in

```sh
blocklive login
```

The terminal shows:

```text
Open https://blocklive.io/cli and enter this code:

    BCDF-GHJK

Waiting for you to approve it there (two-step verification needed)…
```

1. Open [blocklive.io/cli](https://blocklive.io/cli) in your browser and sign
   in to Blocklive if you aren't already.
2. **Sign in the Blocklive CLI** asks for the code. Type it and press
   **Continue**.
3. If you haven't confirmed two-step verification in the last 10 minutes, the
   page asks: **Confirm it's you before a CLI signs in as you.** Enter the code
   from your authenticator app, or use your security key.
4. Check what the page shows: the code (it must match your terminal), the
   computer (its name, system and CLI version), and when and from which
   country and network the login was asked for.
5. Choose what the sign-in can do (below) and press **Approve**. The page says
   **Approved. Go back to your terminal.**
6. Within a few seconds the terminal says `Signed in as <you> at <where>.`

The code is never filled in for you: you type it, so a link someone sends you
can't sign you in. **Refuse** ends the login, and the terminal says
`The sign-in was refused.`

> **Warning:** Only approve if you ran `blocklive login` yourself just now.
> Blocklive never asks you to enter a code someone sent you.

If the page says **The Blocklive CLI needs two-step verification on your
account**, press **Turn on two-step verification** and set it up. Then open
[blocklive.io/cli](https://blocklive.io/cli) again and enter the code: it
works for 10 minutes from `blocklive login`.

## What you choose when you approve

| Choice      | What it means                                                                                                                                                                                   |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Act         | **With your roles**, or **Through an API key you manage**. Shown only if you have both.                                                                                                         |
| Where       | With your roles: the organizations, teams and events the sign-in can see. Pick at least one.                                                                                                    |
| Through     | With an API key: which key. The sign-in reads what that key reads.                                                                                                                              |
| It may also | **Check guests in and out**, **Add guests with free tickets**, **Edit drafts and make unpublished events**. No CLI command uses these yet, so leave them unticked: the sign-in can always read. |

Above **Approve**, a summary says in plain words what the sign-in can do,
where, and when it ends. Anything it does is recorded as you.

A sign-in through an API key lists the key's events only; read one event or
its attendees with the [developer API](https://blocklive.io/docs/developers) and the key itself.

## Login limits

| Limit                    | Value                                                                                          |
| ------------------------ | ---------------------------------------------------------------------------------------------- |
| A code works for         | 10 minutes. Then the terminal says `The code expired before it was approved.` Run login again. |
| Codes tried, per account | 50 an hour, right or wrong.                                                                    |
| Logins, per network      | 10 a minute.                                                                                   |

## How long a sign-in lasts

A sign-in lasts at most 12 hours. It ends sooner when:

-   it isn't used for 1 hour (8 hours if all it may do besides reading is check
    guests in and out);
-   you run `blocklive logout`;
-   you sign out of Blocklive in your browser, or the browser session you
    approved it from ends;
-   you turn off two-step verification;
-   you no longer hold a role at any place it acts at, or the API key it acts
    through stops;
-   a copy of it is used on another computer.

When it has ended, commands stop with `not_signed_in` (exit code 3). Run
`blocklive login` again.

The CLI renews its access every 15 minutes on its own, and each renewal can be
used once. If a copy of your sign-in is used somewhere else, both stop with
`This sign-in was used from somewhere else, so it ended.`

## Check who you are

```sh
blocklive whoami
```

```text
Sam Lee at Summer Festival, Night Market
May: read only
Ends: 2026-11-06T06:00:00.123456+00:00
```

`May` lists what it may do besides reading. A sign-in through an API key says
`through the key "<key name>"` instead of the places.

## Sign out

```sh
blocklive logout
```

This ends the sign-in on Blocklive too, not only on this computer. If
Blocklive can't be reached, the CLI still forgets the sign-in here and says
`Signed out here. Blocklive could not be reached`; the sign-in then ends on its
own (see above).

## Profiles

Keep more than one sign-in, for example one per organization, with
`--profile`:

```sh
blocklive login --profile festival
```

```sh
blocklive events list --profile festival
```

Without `--profile`, commands use the profile called `default`. A profile name
is up to 32 lower-case letters, digits, `-` or `_`.

## Where the sign-in is kept

| Computer | Stored in                                                             |
| -------- | --------------------------------------------------------------------- |
| macOS    | The login Keychain.                                                   |
| Linux    | The Secret Service (GNOME Keyring or KWallet), through `secret-tool`. |
| Other    | Only with `--insecure-storage`: a file readable by you only.          |

Without a keychain or `--insecure-storage`, `blocklive login` stops with
`No keychain here to keep your sign-in.` Which address each profile uses is
kept in `~/.config/blocklive/config.json`, or under
`$XDG_CONFIG_HOME/blocklive`.

The CLI never prints the sign-in's tokens, and there's no environment variable
for them. For a script that runs unattended, use an API key with the
[developer API](https://blocklive.io/docs/developers) instead.
