Authorization: Bearer <token>. There are two ways to get that token:
- OAuth2 (recommended) — send your API owner email, password, and a Leaf-provisioned
client_idto get anaccess_tokenand arefresh_token. Put theaccess_tokenin the Bearer header and callhttps://api-v2.withleaf.io. When it expires, exchange therefresh_tokenfor a new access token without re-sending your password. /authenticate— send your API owner email and password to get anid_token. There is no refresh token; when it expires, authenticate again. Callhttps://api.withleaf.io.
OAuth2 token endpoint
POST https://auth.withleaf.io/realms/leaf/protocol/openid-connect/token
Requests use Content-Type: application/x-www-form-urlencoded. Two grant types are supported: Username/Password and refresh token.
Username/Password Grant
Uses your API owner credentials together with aclient_id.
Refresh token grant
Exchange a refresh token for a new access token without re-sending credentials.Response
access_token in the Authorization: Bearer <token> header of every API request. When it expires, use the refresh token grant to obtain a new one.
Token lifetimes (
expires_in, refresh_expires_in) are configured per client; the values above are examples and may differ for yours.Error responses
Legacy /authenticate method
Email and password for an id_token. No refresh token. API calls go to https://api.withleaf.io.
POST /authenticate
Base URL
Request body
Token duration
When a token expires, request a new one from the same endpoint. There is no refresh token flow.
Request
Response
Using the token
Include the token in theAuthorization header of every API request:

