# Authenticate

The CLI signs you in through your browser and keeps a refreshing **account session** at `~/.stream/auth.yaml`. You sign in once per machine.

## Sign in with `init`

`getstream init` links a directory to one of your apps. When there's no session on the machine, it signs you in first:

```bash
cd path/to/your/project
getstream init
```

With no session, `init` opens your browser to log in with the [Stream Dashboard](https://getstream.io/signin/), writes the refreshing session, then moves on to linking the app. See [Projects and credentials](https://getstream.io/cli/docs/concepts/projects-and-credentials/) for what the link writes, or the [Quickstart](https://getstream.io/cli/docs/quickstart/) for the setup end to end.

## Sign in without linking a project

To create the session on its own, run:

```bash
getstream login
```

This goes through the same browser flow and same session file as above, but doesn't link a project. Use it to sign back in after a guest session or on a machine where you reach apps with `--app-id` rather than a linked project.

## Try the CLI without an account

```bash
getstream login --guest
```

Creates a temporary guest account backed by a throwaway app, so you can run commands before signing up. It needs no browser or email, so it can be used by agents and in headless environments that start with no credentials. Run it before `init` and the sign-in is already done, so `init` goes straight to linking an app.

A machine holds one session at a time, so `--guest` replaces a session already on the machine; `getstream login` gets your real account back. When you're ready to keep your work, convert the guest into a real account:

```bash
getstream login --upgrade
```

This opens the dashboard to finish creating a personal account.

## Target another app for one call

```bash
getstream api GetApp --app-id 99999
```

`--app-id` resolves any app you own through your account session, without changing the linked project.

## Log out

```bash
getstream logout
```

Clears `~/.stream/auth.yaml`. Logging out of a guest account discards it, so the CLI asks for confirmation; pass `--force` to skip the prompt in a script.

## Related

- [Use the CLI in CI](https://getstream.io/cli/docs/ci/): for headless environments with no browser
- [`getstream env`](https://getstream.io/cli/docs/commands/env/): write SDK keys into the project you're developing

---

For the most recent version of this documentation, visit [https://getstream.io/cli/docs/authentication/](https://getstream.io/cli/docs/authentication/).