> ## 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.

# DPoP

> Bind a person's tokens to your app's own key, so a copied token is useless (RFC 9449).

DPoP (Demonstrating Proof of Possession, RFC 9449) binds the tokens Aiveth gives your app to a key pair your app holds. Every request that uses the token must carry a fresh proof signed with that key. If someone copies the token from a log or a browser, it is worthless without the private key.

DPoP is available on every plan.

## What Aiveth binds

* **Bound:** tokens for a person, from the `authorization_code`, `refresh_token` and device code grants.
* **Where a bound token works:** `/oauth/userinfo`.
* **A public app's refresh tokens:** bound to the same key. Every refresh needs a proof from that key.
* **Not bound:** machine tokens and AI agent tokens. They are JWTs read by your own servers.

Aiveth doesn't use server nonces (`DPoP-Nonce`).

## Turn on DPoP

Your app gets a bound token whenever it sends a DPoP proof with its token request, with no setting needed. To refuse token requests that don't send one:

**1. Open the app**

In the console, open **Apps** and select the app.

**2. Require DPoP**

Under **Require DPoP**, select **Turn on**. Do this once your app always sends a proof.

With **Require DPoP** on, a person's token request without a proof is refused with `invalid_dpop_proof`.

## At the token endpoint

Add a `DPoP` header to the token request. It is a JWT that your app signs with its private key:

* Header: `typ` is `dpop+jwt`, `alg` is `ES256` or `RS256`, and `jwk` is your public key.
* Claims: `htm` is `POST`, `htu` is the token endpoint's address (`https://accounts.aiveth.com/oauth/token`), `iat` is now, and `jti` is a unique value.

```http theme={null}
POST /oauth/token HTTP/1.1
Host: accounts.aiveth.com
Content-Type: application/x-www-form-urlencoded
DPoP: eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVTMjU2IiwiandrIjp7Li4ufX0...

grant_type=authorization_code&code=...&redirect_uri=...&code_verifier=...&client_id=...
```

The answer's `token_type` is `DPoP` instead of `Bearer`:

```json theme={null}
{
  "access_token": "...",
  "token_type": "DPoP",
  "expires_in": 3600,
  "scope": "openid email",
  "id_token": "..."
}
```

## At userinfo

Send a bound token with the `DPoP` scheme and a new proof for this request:

```http theme={null}
GET /oauth/userinfo HTTP/1.1
Host: accounts.aiveth.com
Authorization: DPoP <access token>
DPoP: <proof with htm=GET, htu=https://accounts.aiveth.com/oauth/userinfo, ath=...>
```

`ath` is the base64url-encoded SHA-256 hash of the access token.

A bound token sent as `Bearer` is refused, and so is an unbound token sent as `DPoP`. A refused request gets `401` with a `WWW-Authenticate` header that names `DPoP` and the algorithms `ES256 RS256`.

## Proof rules

Aiveth refuses a proof when:

* `typ`, `alg` or `jwk` is wrong or missing,
* `htm` is not the request's method, or `htu` is not the request's address (query and fragment are ignored),
* `iat` is more than 5 minutes away from now,
* `jti` is missing or longer than 256 characters, or the same `jti` was already used with that key,
* `ath` doesn't match the token (at userinfo),
* the request has more than one `DPoP` header.

At the token endpoint, a refused proof answers `400` with `"error": "invalid_dpop_proof"` and an `error_description` that says why.

## Refresh tokens

A refresh token that was bound must come with a proof from the same key. A proof from a different key is refused with `invalid_dpop_proof`, before the refresh token is swapped.

## Browser apps

Aiveth's CORS rules allow the `DPoP` header on the token, userinfo and revoke endpoints, so a [single-page app](https://docs.aiveth.com/apps/single-page-apps.md) can use DPoP. Keep the private key non-extractable, for example with the Web Crypto API.

## Related

* [Tokens and claims](https://docs.aiveth.com/apps/tokens-and-claims.md)
* [OpenID Connect endpoints](https://docs.aiveth.com/api-reference/oidc-endpoints.md)
* [Session security](https://docs.aiveth.com/sign-in/session-security.md)


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