Davi is an OAuth 2.0 authorization server and an OpenID Connect provider.
Hosts
| Host | Serves |
|---|---|
https://davi.social/oauth/authorize | The sign-in and consent screens. Send the user's browser here |
https://api.davi.social/oauth2 | Every endpoint your server calls |
Endpoints
Paths are under https://api.davi.social/oauth2.
| Endpoint | Purpose |
|---|---|
POST /token | Exchange a code, refresh, run client credentials or token exchange |
GET /userinfo | The claims for the current access token |
POST /introspect | Whether a token is active (RFC 7662) |
POST /revoke | Revoke a token (RFC 7009). Ends the session it belongs to |
GET /.well-known/openid-configuration | The discovery document |
GET /.well-known/jwks.json | Public keys for verifying token signatures |
The discovery document lists every endpoint above, the browser authorization
endpoint, and every scope that can be requested (scopes_supported).
curl "https://api.davi.social/oauth2/.well-known/openid-configuration"
OAuth endpoints return errors in the RFC 6749 shape,
{ "error": "...", "error_description": "..." }, not the
API error envelope.
Grant types
| Grant | Use it for | Enabled on a new app |
|---|---|---|
authorization_code | Signing in a user. PKCE with S256 is required | Yes |
refresh_token | Renewing a user's access token | Yes |
urn:ietf:params:oauth:grant-type:token-exchange | Exchanging a user token for an org-scoped token | No |
client_credentials | Acting as the app itself, with no user. Confidential apps only | No |
Enable a grant on the app's page in the dashboard, under Developer → Apps. A grant the app does not have is refused at the token endpoint.
| Parameter | Supported |
|---|---|
response_type | code |
code_challenge_method | S256 |
| Token endpoint authentication | client_secret_basic, client_secret_post, or none for a public client |
Tokens
| Token | Lifetime | Notes |
|---|---|---|
| Authorization code | 10 minutes | Single use |
| Access token | 1 hour | expires_in on the token response is authoritative |
| Refresh token | 30 days from its last use | Rotates on every refresh |
| Org-scoped token | 1 hour | No refresh token. Exchange again |
| Client credentials token | 1 hour | No refresh token. Request another |
The app's page in the dashboard shows the lifetimes it was registered with.
Refresh token rotation
- Every refresh returns a new refresh token and retires the one you sent. Store the new one before using it.
- Presenting a retired refresh token revokes the whole session. Two concurrent refreshes, or a retry that re-sends a used token, log the user out.
- Every refresh starts a new 30-day window. A refresh token unused for the whole window expires, and the user has to sign in again.
- A refresh may request a narrower
scope, never a wider one. - A user revoking your app from their Davi settings revokes its sessions, and the next refresh fails.
Token response
{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "def502...",
"scope": "openid user:read",
"id_token": "eyJhbGciOi..."
}
| Field | Present |
|---|---|
refresh_token | On the authorization code and refresh grants |
id_token | When openid was granted |
scope | Always. The scopes actually granted, which can be fewer than requested |
issued_token_type | On token exchange |
ID token
An RS256-signed JWT, issued when the granted scopes include openid.
| Claim | Value |
|---|---|
iss | The issuer from the discovery document |
sub | The user's Davi account id. Stable for the life of the account |
aud | Your client_id |
exp, iat | Expiry and issue time |
auth_time | When the user authorized |
nonce | The nonce you sent, if you sent one |
email, email_verified | The account's email address and whether it is verified |
org_membership | Present when membership:read was granted. See below |
sub is not the user's uuid from GET /api/v1/users/me, and API paths and
identifiers that take a user ({user_uuid}, user_id) do not accept it. To
address the user in the API, read uuid from /users/me.
The ID token carries no name, username or avatar. profile is accepted as a
scope and adds no claims; read those fields from GET /api/v1/users/me.
GET /userinfo returns sub, email and email_verified for the access
token's user.
org_membership
When the granted scopes include membership:read, the ID token describes the
user's membership in the organization that registered the app:
{
"org_membership": {
"org_uuid": "…",
"has_membership": true,
"tier_uuid": "…",
"tier_slug": "gold",
"entitlements": { "member": null, "community.access": null }
}
}
A user with no membership has has_membership: false and no tier fields. The
claim is a snapshot from sign-in. For the current state, read
membership entitlements.
Verifying a token
- Offline. Verify the RS256 signature against the keys at
jwks_uri, selecting by the token'skid. Checkissagainst the discoveryissuerexactly,audagainst yourclient_id, andexp. - Online.
POST /introspect, authenticated as your app. It reportsactive: trueonly for a token issued to your own app, andactive: falsefor any other.
Next
- Sign In a User: the flow these endpoints serve.
- Request Scopes: what an app can request.