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

# Login with Aiveth

> Register an app and sign your people in with OpenID Connect, the authorization code flow and PKCE.

"Login with Aiveth" lets your app sign people in through Aiveth instead of keeping its own passwords. Aiveth is an OpenID Connect provider. Your app sends the person to Aiveth, Aiveth signs them in with your organization's rules (two-step, passkeys, single sign-on and so on), and your app gets tokens that say who they are.

For a step-by-step first integration, see the [Quickstart](https://docs.aiveth.com/quickstart.md).

## Register an app

**1. Open Apps**

In the console, open **Apps** and select **Register app**. You need the `apps:manage` power.

**2. Choose the kind**

* **Server app**: a web app with its own server. It keeps a secret.
* **Browser or mobile app**: a single-page or phone app. It can't keep a secret, so it proves itself with PKCE alone.
* **Machine**: a service that signs in as itself, with no person. See [Machine-to-machine](https://docs.aiveth.com/apps/machine-to-machine.md).

**3. Add return addresses**

Under **Return addresses**, add one address per line. Aiveth sends people back only to these exact addresses.

**4. Copy the credentials**

Copy the **Client ID**, and the **Client secret** for a server app. The secret is shown once.

Select an app in the list to open its panel. There you can see its status, change its sign-out settings, set how long it keeps people signed in, and turn features such as device login and DPoP on or off.

## Return address rules

* The address must be absolute and must not contain a `#fragment`.
* It must use https. `http` is allowed only for `localhost`, `127.0.0.1` or `[::1]`.
* In Production, localhost addresses are refused. Use your [Development environment](https://docs.aiveth.com/environments.md) while you build.
* The address in the authorization request must match a registered one exactly.
* For a native app that listens on a loopback address: if you register the loopback address **without** a port, Aiveth accepts the same address on any port (RFC 8252).

## How the flow works

1. Your app redirects the browser to `/oauth/authorize` with `response_type=code`, a `scope` that includes `openid`, and a PKCE `code_challenge` with `code_challenge_method=S256`.
2. If the person is not signed in to Aiveth, Aiveth shows your organization's sign-in page. If they are, Aiveth continues straight away.
3. Before it issues a code, Aiveth may show the person a screen: your organization's terms, a consent notice, or a "Confirm it's you" step when your app asked for one.
4. Aiveth redirects to your return address with `code`, `state` and `iss`.
5. Your server posts the code and the `code_verifier` to `/oauth/token` and gets an ID token and an access token.

> [!NOTE]
>
> PKCE with `S256` is required for every app, public or confidential. A request without it gets `invalid_request`.

## Rules Aiveth enforces

* **One organization per app.** An app signs in only people of the organization that registered it. Anyone else gets `access_denied`.
* **Codes are single use.** A code lasts two minutes and works once, for the app and return address it was issued to. A second attempt fails, right or wrong.
* **The person must still be able to sign in.** A suspended person, or a person whose organization is suspended, gets no tokens.
* **A turned-off app signs nobody in.** In the app's panel, **Turn off** stops all sign-ins until the app is registered again.
* **Your organization's sign-in check runs first.** If you set up a sign-in check under **Developers**, Aiveth asks your server before every sign-in and every token refresh.

## Scopes

| Scope | What it adds |
| - | - |
| `openid` | Required. The ID token, with `sub` and `org_id`. |
| `email` | `email` and `email_verified`. |
| `profile` | `name`, `given_name`, `family_name`, and `picture` when the person has a photo. |
| `roles` | `role` and that role's app `permissions`. |
| `groups` | `groups`: the names of the person's groups. |
| `offline_access` | A refresh token, so the app stays signed in after the Aiveth session ends. |

See [Tokens and claims](https://docs.aiveth.com/apps/tokens-and-claims.md) for every claim.

## Ask the person to confirm it's them

For a sensitive step, send the person to `/oauth/authorize` again with one of these:

* `acr_values=urn:aiveth:acr:2fa`: the person must have proved a second factor (a two-step code or a passkey) in this session. A remembered device or a password-only sign-in doesn't count.
* `max_age=N`: the person must have proved it's them in the last `N` seconds.
* `prompt=login`: the person must prove it's them now.
* `prompt=none`: never show a screen. Aiveth answers `login_required` or `interaction_required` instead.

The ID token's `acr` is `urn:aiveth:acr:2fa` when the session proved a second factor, and `urn:aiveth:acr:1fa` otherwise. `auth_time` is the time of the latest proof. If the person has no second factor, an `acr_values` request ends with `unmet_authentication_requirements`.

## Errors in the redirect

When Aiveth can trust the return address, it reports errors there as `error` and `error_description`, with your `state`:

| Error | Why |
| - | - |
| `unsupported_response_type` | `response_type` was not `code`. |
| `invalid_scope` | `scope` is missing `openid` or has an unknown value. |
| `invalid_request` | PKCE is missing, or `max_age` / `prompt` can't be read. |
| `access_denied` | The person is not in the app's organization, your sign-in check refused them, or they have not agreed to the terms while someone acts for them. |
| `login_required` | `prompt=none` and nobody is signed in. |
| `interaction_required` | `prompt=none` and the person needs to confirm. |
| `unmet_authentication_requirements` | `acr_values` asked for a second factor the person doesn't have. |

If the app is unknown or the return address is not registered, Aiveth never redirects. It shows an error page instead.

## Related

* [OpenID Connect endpoints](https://docs.aiveth.com/api-reference/oidc-endpoints.md)
* [Single-page apps](https://docs.aiveth.com/apps/single-page-apps.md)
* [Logout](https://docs.aiveth.com/apps/logout.md)
* [Step-up and remembered devices](https://docs.aiveth.com/sign-in/step-up-and-remembered-devices.md)


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