OAuth apps: install and consent
Register an OAuth app, send a merchant through the consent screen with PKCE and exchange the code for access and refresh tokens.
Rolling out gradually; it may not be active for your business yet
OAuth apps are enabled per business. Registering, installing and revoking all require the owner or administrator of the business.
How it works
An OAuth app is registered once by a developer business. A merchant installs it on their business by approving a consent screen listing the scopes requested. The app then receives an access token for the Admin API, the storefront Platform API, or both, depending on the scopes granted. The flow is the standard authorization-code flow with PKCE (S256).
Register an app
POST /api/businesses/:businessId/apps/registrations with a signed-in owner or administrator session of the developer business.
{
"name": "Stock sync",
"redirectUris": ["https://app.example.com/nimlio/callback"],
"scopes": ["products:read", "inventory:write"]
}name: 1–120 characters.redirectUris: 1–10 URIs of up to 2048 characters.scopes: 1–17 of the Admin scopes and the Platform API scopes, mixed freely.- The answer (201) contains
clientIdandclientSecret. Copy the secret now: it is shown only once. - Redirect URIs are matched exactly at consent time.
Install: send the merchant to consent
- Create the PKCE pair
Generate a random
code_verifier(43–128 characters) and itscode_challenge: the Base64URL of the SHA-256 of the verifier. OnlyS256is accepted. - Open the consent page
Redirect the merchant's browser to
https://<your-nimlio-host>/oauth/authorizewithclient_id,redirect_uri,response_type=code,scope(space separated, a subset of what you registered),state,code_challengeandcode_challenge_method=S256. The merchant signs in if needed and picks the business to install on, among those where they are owner or administrator. - The merchant decides
The consent screen shows the app, its developer and the scopes. Approve installs the app on the chosen business; Deny installs nothing.
- Receive the redirect
Nimlio redirects to your
redirect_uriwithcodeand yourstate(approve) orerror=access_deniedandstate(deny). Check thatstatematches what you sent. The code is single-use and expires in 10 minutes.
If client_id or redirect_uri is unknown, Nimlio does not redirect (it would be unsafe) and shows the error instead: invalid_client, invalid_redirect_uri. A missing PKCE challenge, a method other than S256 or a wrong response_type answers invalid_request; an unknown or unregistered scope answers invalid_scope.
The consent page itself reads and decides through GET and POST /api/oauth/authorize. Your app does not call them: it only sends the browser to the consent page.
Exchange the code for tokens
POST /api/v1/oauth/token, as application/x-www-form-urlencoded or JSON. Authenticate the client with client_id and client_secret in the body or with HTTP Basic.
curl -X POST "https://<your-nimlio-host>/api/v1/oauth/token" \
-d grant_type=authorization_code \
-d code=<code> \
-d redirect_uri=https://app.example.com/nimlio/callback \
-d code_verifier=<code_verifier> \
-d client_id=<client_id> \
-d client_secret=<client_secret>{
"access_token": "nmat_…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "…",
"scope": "inventory:write products:read"
}| Token | Lifetime |
|---|---|
| Authorization code | 10 minutes, single use |
Access token (nmat_…) | 1 hour |
| Refresh token | 90 days, rotated on every use |
Refresh
curl -X POST "https://<your-nimlio-host>/api/v1/oauth/token" \
-d grant_type=refresh_token \
-d refresh_token=<refresh_token> \
-d client_id=<client_id> \
-d client_secret=<client_secret>Every refresh returns a new pair and revokes the old refresh token. Presenting an already-used refresh token again revokes the installation's tokens, so save the new one before you use the new access token.
Platform API scopes
An app can also call the storefront Platform API (/api/v1/*) on behalf of the merchant. Request the platform: scopes below, alone or together with Admin scopes. The merchant sees and approves or denies them on the same consent screen. Each one unlocks the matching Platform API route scope.
| OAuth scope | Unlocks |
|---|---|
platform:catalog:read | catalog:read: products, services, collections, staff and gallery |
platform:content:read | content:read: site content and CMS entries |
platform:booking:read | booking:read: booking availability and context |
platform:booking:write | booking:write: create and manage bookings |
platform:orders:write | orders:write: create orders and carts, upload payment proofs |
platform:leads:write | leads:write: leads, forms, newsletter and restock signups |
Event ingestion (events:write) has no OAuth scope: it stays available with a site publishable key only.
curl "https://<your-nimlio-host>/api/v1/products" \
-H "Authorization: Bearer nmat_…"- Send the access token as
Authorization: Bearer nmat_…. TheX-Nimlio-Keyheader is only for publishable keys, not for OAuth tokens. - The effective scopes are the token's scopes intersected with the installation's, as for the Admin API, so a merchant who reduces an installation takes effect immediately. A route whose scope is missing answers 403.
- Access tokens last 1 hour; refresh tokens last 90 days and rotate on every use (see Refresh). Uninstalling the app revokes all its tokens.
- Platform OAuth needs the same access as Admin apps: the OAuth apps feature must be enabled for the businesses involved (see the availability note above).
Revoke and uninstall
- Your app can revoke a token with
POST /api/v1/oauth/revokeandtoken(RFC 7009; optionaltoken_type_hint), authenticating as at the token endpoint. The answer is{ "revoked": true }. - The merchant uninstalls the app from Dashboard → Integrations. This is
DELETE /api/businesses/:businessId/apps/:installationId(?revision=is required to guard against concurrent changes: missing is 400invalid_input, stale is 409revision_conflict). All the installation's tokens stop working. - Installing again with fewer scopes revokes the live tokens that carried the withdrawn scopes.
Token endpoint errors
| Code | Status | When |
|---|---|---|
invalid_client | 401 | Unknown client or wrong secret |
invalid_request | 400 | Missing or malformed parameter, or no grant_type |
unsupported_grant_type | 400 | Anything other than authorization_code or refresh_token |
invalid_grant | 400 | Expired, used or unknown code; wrong redirect_uri or code_verifier; expired or revoked refresh token; installation or app revoked |
Responses carry Cache-Control: no-store. The token and revoke endpoints are rate limited per client and IP.