> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-cli/authentication.md).

# Authentication

`baas login` authenticates you with BaaS through your browser. Once you're logged in, every other command uses your session automatically.

## Log in

```bash
baas login
# Opening your browser to log in to BaaS...
# ✔ Logged in as you@example.com
```

Your browser opens to authenticate. On success, your tokens are saved to `~/.baas/credentials.json` and refreshed automatically before they expire, so you won't need to log in again.

If you're already logged in, the CLI asks before re-authenticating:

```bash
baas login
# ? Already logged in as you@example.com. Log in again? (y/N)
```

Answer `y` to re-authenticate, or `N` to keep your current session.

## Log out

```bash
baas logout
```

Revokes the CLI session on the server and removes your local credentials.

{% hint style="info" %}
**Where your credentials live:** `~/.baas/credentials.json`, with `0600` permissions (readable only by you). It holds your access and refresh tokens; **no wallet private key is ever stored** (relayer deployments sign server-side).
{% endhint %}

<details>

<summary>Under the hood (OAuth 2.0 + PKCE)</summary>

`baas login` runs the standard browser-based OAuth 2.0 Authorization Code flow with PKCE. The CLI starts a short-lived local server on `127.0.0.1`, opens your browser to authorize, receives the callback (validated with a `state` parameter), and exchanges the code for tokens. You don't need to know any of this to use the CLI.

</details>

## Next

* [Projects](/baas-cli/projects.md) — list your projects and choose the active one.
* [Troubleshooting](broken://pages/2QIKRDlpLdXoaDPZhTBj) — fixes for `Not logged in` and `Session expired`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.baas.sh/baas-cli/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
