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.

Availability

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.

Body
{
"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 clientId and clientSecret. Copy the secret now: it is shown only once.
  • Redirect URIs are matched exactly at consent time.

Install: send the merchant to consent

  1. Create the PKCE pair

    Generate a random code_verifier (43–128 characters) and its code_challenge: the Base64URL of the SHA-256 of the verifier. Only S256 is accepted.

  2. Open the consent page

    Redirect the merchant's browser to https://<your-nimlio-host>/oauth/authorize with client_id, redirect_uri, response_type=code, scope (space separated, a subset of what you registered), state, code_challenge and code_challenge_method=S256. The merchant signs in if needed and picks the business to install on, among those where they are owner or administrator.

  3. 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.

  4. Receive the redirect

    Nimlio redirects to your redirect_uri with code and your state (approve) or error=access_denied and state (deny). Check that state matches what you sent. The code is single-use and expires in 10 minutes.

Errors before the redirect

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.

authorization_code
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>
Response
{
"access_token": "nmat_…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "…",
"scope": "inventory:write products:read"
}
TokenLifetime
Authorization code10 minutes, single use
Access token (nmat_…)1 hour
Refresh token90 days, rotated on every use

Refresh

refresh_token
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>
Store the new refresh token

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 scopeUnlocks
platform:catalog:readcatalog:read: products, services, collections, staff and gallery
platform:content:readcontent:read: site content and CMS entries
platform:booking:readbooking:read: booking availability and context
platform:booking:writebooking:write: create and manage bookings
platform:orders:writeorders:write: create orders and carts, upload payment proofs
platform:leads:writeleads:write: leads, forms, newsletter and restock signups

Event ingestion (events:write) has no OAuth scope: it stays available with a site publishable key only.

Call the Platform API with an access token
curl "https://<your-nimlio-host>/api/v1/products" \
-H "Authorization: Bearer nmat_…"
  • Send the access token as Authorization: Bearer nmat_…. The X-Nimlio-Key header 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/revoke and token (RFC 7009; optional token_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 400 invalid_input, stale is 409 revision_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

CodeStatusWhen
invalid_client401Unknown client or wrong secret
invalid_request400Missing or malformed parameter, or no grant_type
unsupported_grant_type400Anything other than authorization_code or refresh_token
invalid_grant400Expired, 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.