Documentation

OAuth Endpoints and Tokens

The authorization server's hosts and endpoints, grant types, token lifetimes and rotation, ID token claims, and how to verify a token.

Davi is an OAuth 2.0 authorization server and an OpenID Connect provider.

Hosts

HostServes
https://davi.social/oauth/authorizeThe sign-in and consent screens. Send the user's browser here
https://api.davi.social/oauth2Every endpoint your server calls

Endpoints

Paths are under https://api.davi.social/oauth2.

EndpointPurpose
POST /tokenExchange a code, refresh, run client credentials or token exchange
GET /userinfoThe claims for the current access token
POST /introspectWhether a token is active (RFC 7662)
POST /revokeRevoke a token (RFC 7009). Ends the session it belongs to
GET /.well-known/openid-configurationThe discovery document
GET /.well-known/jwks.jsonPublic 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

GrantUse it forEnabled on a new app
authorization_codeSigning in a user. PKCE with S256 is requiredYes
refresh_tokenRenewing a user's access tokenYes
urn:ietf:params:oauth:grant-type:token-exchangeExchanging a user token for an org-scoped tokenNo
client_credentialsActing as the app itself, with no user. Confidential apps onlyNo

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.

ParameterSupported
response_typecode
code_challenge_methodS256
Token endpoint authenticationclient_secret_basic, client_secret_post, or none for a public client

Tokens

TokenLifetimeNotes
Authorization code10 minutesSingle use
Access token1 hourexpires_in on the token response is authoritative
Refresh token30 days from its last useRotates on every refresh
Org-scoped token1 hourNo refresh token. Exchange again
Client credentials token1 hourNo 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..."
}
FieldPresent
refresh_tokenOn the authorization code and refresh grants
id_tokenWhen openid was granted
scopeAlways. The scopes actually granted, which can be fewer than requested
issued_token_typeOn token exchange

ID token

An RS256-signed JWT, issued when the granted scopes include openid.

ClaimValue
issThe issuer from the discovery document
subThe user's Davi account id. Stable for the life of the account
audYour client_id
exp, iatExpiry and issue time
auth_timeWhen the user authorized
nonceThe nonce you sent, if you sent one
email, email_verifiedThe account's email address and whether it is verified
org_membershipPresent 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's kid. Check iss against the discovery issuer exactly, aud against your client_id, and exp.
  • Online. POST /introspect, authenticated as your app. It reports active: true only for a token issued to your own app, and active: false for any other.

Next