> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlurk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign-in with Clerk

> Trust your Clerk instance so the people who sign in to your app can read their own balance and receipts. Clerk session tokens only.

Lurk accepts the **session token** Clerk gives a signed-in person. It does not accept a token made from a Clerk JWT template. There is no template to set up.

## What Lurk requires of a Clerk token

* It is a version 2 session token: it carries `sid`, `v` set to `2` and `sts` set to `active`.
* It is signed with `RS256`.
* Its `azp` claim (the origin of your app, as Clerk records it) is exactly one of the origins you list.
* It carries no `aud`, unless you list audiences. If you list some, it must carry exactly one of them.
* It is refused as a pending session when `sts` is `pending`, which Clerk uses when someone has not finished joining an organization.

A token from a JWT template is refused, with or without `azp` or `aud`, because it is not tied to a session. A version 1 session token is refused too. No setting turns these on.

A request from a client that sends no `Origin` header can produce a token with no `azp`. Lurk refuses it.

## What you need from Clerk

| You need | Where it comes from |
| - | - |
| The Frontend API address | Your Clerk instance. In production it is an address like `https://clerk.your-site.com`. In development it is `https://<name>.clerk.accounts.dev`. |
| The origins of your app | The exact HTTPS origins your sign-in runs on, such as `https://app.your-site.com`. No path, no wildcard. |

The Frontend API address must be written exactly as Clerk puts it in `iss`: HTTPS, lower case, no port, no path and no query. A trailing slash is refused when you save it.

A development instance may also list `http://localhost` or `http://127.0.0.1`, with an optional port. A production instance may not.

## Add it to Lurk

An owner or admin does this, in person. In the dashboard, open Settings, then the Sign-in tab, and choose **Add a provider**. Or call `POST /v1/trusted-issuers` as a member.

| Field | Value |
| - | - |
| `name` | A name for you, up to 80 characters. |
| `profile.provider` | `clerk` |
| `profile.issuer` | Your Frontend API address. |
| `profile.authorized_parties` | One to 20 origins. |
| `profile.audiences` | Leave empty unless your tokens carry one audience. |
| `profile.max_token_lifetime_seconds` | Optional. See [the overview](https://docs.getlurk.com/end-user-auth/overview.md#what-the-token-must-carry). |

The issuer is saved **paused**. Its address cannot be edited later. To change it, add a new issuer.

A Clerk development address (`*.clerk.accounts.dev`) cannot be saved with the `oidc` profile. Use `clerk`.

## Check the keys, then turn it on

1. **Check keys.** In the dashboard, choose **Check keys**. Or `POST /v1/trusted-issuers/{id}/check` with the `expected_revision` you read from the issuer. Lurk fetches the keys from `<issuer>/.well-known/jwks.json` and saves what it found.
2. **Turn it on.** Choose **Turn on**, or `POST /v1/trusted-issuers/{id}/activate` with `expected_revision`. It is refused unless the last check is at the current revision and at most 24 hours old.
3. **Allow new people.** A person who has never signed in is refused until the project saves a limit on new people per hour (`new_people_per_hour`, 1 to 1,000) in the dashboard, under Settings > Sign-in, in **Events people’s apps may send**. Also list the event names a device may send. The list is empty by default. See [Client API](https://docs.getlurk.com/end-user-auth/client-api.md).

## Test it

Sign in to your app, take the session token Clerk gives it, and test it against the issuer. In the dashboard, choose **Test a token** on the issuer and paste it. See [Linking people](https://docs.getlurk.com/end-user-auth/linking-people.md#test-a-token).

A good answer is `verified`, with `identity` `linked` or `unlinked` and `access` `ready`. A refusal names the claim that failed: `wrong_authorized_party` means `azp` is not in your list, `pending_session` means the session is not finished, and `wrong_audience` means the audience does not match. A JWT-template token is answered as `invalid_token`.

Clerk session tokens live for 60 seconds, so paste a fresh one. See [Troubleshooting](https://docs.getlurk.com/end-user-auth/troubleshooting.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.