# Authenticate the CLI

> Sign in or create a scoped credential for CI and coding agents.

Source: https://www.sorus.run/docs/guides/authentication
Reviewed: 2026-10-21

You need the [public client](https://www.sorus.run/docs/sorus-ci#install) and access to the intended repository.

## Sign in

Run:

```sh
sorus login
```

Open the printed approval page, sign in and approve the matching device code. Then check your identity and repository setup:

```sh
sorus whoami
sorus onboarding status
```

The client stores the login in `$XDG_CONFIG_HOME/lathe/credentials.json`, or `$HOME/.config/lathe/credentials.json` when `XDG_CONFIG_HOME` is unset. The directory retains the earlier product name for compatibility.

## CI and agent credentials

From an identity allowed to manage credentials, create one for the caller:

```sh
sorus credential create ci --scope read --scope submit --expires 30d --requests-per-minute 60
```

This example allows reading and submitting work for 30 days with a limit of 60 requests per minute. Choose the scopes, expiry and rate limit appropriate for your automation.

The value is printed once. Save it directly in the CI or agent host's secret store. Inject it as `SORUS_TOKEN` only into the process that calls Sorus. Do not put it in source control, prompts, logs or URLs, or pass it into the remote build as a job variable.

Run `sorus whoami` with that credential to verify the identity before enabling submissions. [CI integration](https://www.sorus.run/docs/guides/ci) shows how to inject the secret into a workflow.

## Settings and credential files

`SORUS_TOKEN` takes precedence over `SORUS_CREDENTIAL_FILE`. To use a file instead, leave `SORUS_TOKEN` unset and set `SORUS_CREDENTIAL_FILE` to a file containing the credential or a stored JSON credential document.

`SORUS_ENDPOINT` selects the API origin; its default is `https://app.lathe.run`. Use another origin only when it has been supplied for your account.

## Scopes and attribution

Grant the scopes the task needs. Reading and submitting jobs does not require permission to change settings or manage other credentials. The [API reference](https://www.sorus.run/docs/reference/api) states the authority required for each operation.

Use named credentials for separate automated callers so their actions can be attributed and their access revoked independently.

## Rotate or revoke access

List credentials without exposing their values:

```sh
sorus credential list
```

To rotate a credential, create one under a new name, update the consumer's secret, verify the new identity, then revoke the previous name:

```sh
sorus credential revoke ci
```

A revoked credential is refused on its next use.

## Authentication failures

Exit `3` means a credential is missing, refused, expired, revoked or out of scope. Check the endpoint and selected identity. Unset an unintended `SORUS_TOKEN` if you meant to use a credential file. Repository authorisation is a separate requirement from a valid login.
