Every API request carries an OAuth 2.0 bearer token:
Authorization: Bearer <access_token>
Which token depends on who the request acts for. Find your integration below, then follow its page.
| Your integration | Token | Page |
|---|---|---|
| Signs a person in, or shows them their own Davi data | A user token | Sign In a User |
| Manages an organization's activities, memberships or rewards while a staff member uses it | An org-scoped token, exchanged from the user's | Act as an Organization |
| Acts for an organization with nobody signed in: a form handler, a nightly job | An org-scoped token, from a stored refresh token | Automate for Your Organization |
| Checks a member's entitlements from the organization's own backend | A client credentials token | Below |
Every one of these starts from an app registered to your organization in the dashboard, under Developer → Apps.
Client types
You choose the client type when you register the app:
| Type | For | Authenticates to the token endpoint with |
|---|---|---|
| Confidential (server-side application) | A server that can keep a secret | Its client secret, as HTTP Basic or form fields |
| Public (client-side application) | An SPA, mobile or desktop app | PKCE alone |
What decides the type is whether the secret can be kept from the user, not whether the app has a backend. A single-page app with an API behind it is public if the secret would be shipped to the browser.
A new app can use the authorization code and refresh grants. Token exchange and client credentials are enabled separately on the app's page, after it is created.
Machine-to-machine (client credentials)
A confidential app with the client_credentials grant enabled can get a
token for itself, with no user:
curl -X POST "https://api.davi.social/oauth2/token" \
-u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "scope=membership:entitlements:read"
The token carries the scopes you request, limited to those the app was registered with. It has no user and no refresh token.
It also carries no organization, so endpoints that act for an organization
refuse it with a 403. The exception is
reading membership entitlements, which takes the
organization from the app's registration. For anything else an organization
does without a person present, see
Automate for Your Organization.
Next
- Sign In a User: the flow every user token comes from.
- Request Scopes: what to request.
- OAuth Endpoints and Tokens: endpoints, lifetimes and ID token claims.