This guide covers the HTTP contract for implementing OAuth in your own application — language-agnostic, with curl examples. To start from working code, the Quickstart scaffolds a complete Node.js reference implementation.
brevo app create or brevo app initclient_id, client_secret, and a registered redirect_uriStore client_secret on the server side only. Never expose it in client-side code, browser environments, or version control.
Send the user to the Brevo authorization endpoint. Your server constructs this URL and redirects the user’s browser.
Parameters:
Always generate a new random state value for each authorization request and verify it in the callback. Requests with a missing or mismatched state must be rejected.
The user sees the Brevo login page, authenticates with their Brevo credentials, and is redirected to your redirect_uri.
After the user authenticates, Brevo redirects to your redirect_uri with:
In your callback handler:
state matches the value you generated in Step 1 — reject mismatchescode — it expires in 10 minutes, exchange it immediatelyIf the user denies access, the callback receives ?error=access_denied&error_description=... instead of ?code=.... Handle this case explicitly in your callback route.
POST the authorization code to the token endpoint along with your client credentials.
Response:
Token fields:
Include the access token as a Bearer token in the Authorization header on every API request.
Response:
All Brevo API endpoints accept Bearer token authentication. See the API reference for available endpoints.
When the access token expires, use the refresh token to obtain a new one without prompting the user to re-authorize.
The response has the same shape as Step 3. Always store the new access_token — and if a new refresh_token is returned, replace the stored one.
client_secret in client-side code or public repositoriesstate per request and validate it in the callbackredirect_uri values in productionlocalStorage or unprotected cookies.env.local or files containing credentials