Skip to main content
If you build software that many BrandGate customers use, such as an ERP, a WMS or an analytics tool, use OAuth instead of asking customers to copy API keys. The customer clicks Connect in your product, approves the access in BrandGate, and you receive tokens that work for that one company. BrandGate follows OAuth 2.1: authorization code flow, PKCE with S256 is always required, redirect URIs must match exactly, and refresh tokens rotate on every use.

1. Register your app

Email BrandGate with:
  • your app’s name and homepage (https://…),
  • the exact redirect URIs you will use,
  • the scopes your app needs,
  • whether the app keeps a secret on a server (confidential) or runs on the user’s device (public).
You receive a client_id (bg_client_…) and, for confidential apps, a client_secret (bg_cs_…), shown once. Apps that BrandGate has reviewed are marked Verified on the consent screen.
MCP clients such as Claude and Cursor can register themselves through dynamic client registration when it is switched on. They are shown as Not verified.

2. Send the user to BrandGate

Create a random code_verifier (43 to 128 characters), derive the challenge, and redirect the user:
redirect_uri may be left out only when your app has exactly one registered. scope may be left out to ask for everything your app is registered for. You may send resource=https://api.brandgate.dev/v1 or https://api.brandgate.dev/mcp (RFC 8707). The user signs in to BrandGate if needed. A company admin sees your app’s name, whether it is verified, where they will be sent back to, and the access in plain language. The request is valid for 10 minutes.

3. Handle the callback

BrandGate redirects back to your redirect_uri:
Check that state is the one you sent and that iss is https://api.brandgate.dev (RFC 9207). If the admin declined, you get error=access_denied instead of code.

4. Exchange the code

The code is valid for 2 minutes and works once.
Use the access token exactly like an API key: Authorization: Bearer bg_at_….

5. Refresh

Access tokens last one hour. Refresh tokens last 90 days and rotate: every refresh returns a new refresh token and the old one stops working. Store the new one before you use the access token.
You may pass a smaller scope to narrow the new access token.
If an old refresh token is used again, BrandGate assumes it was stolen and revokes the whole connection. The customer then has to connect again. Make sure two workers never refresh the same token at the same time.

Disconnecting

The customer can disconnect your app at any time in Settings → Developers → Connected apps; all its tokens stop working immediately. You can also revoke a token yourself (RFC 7009):
Revoking a refresh token also revokes every access and refresh token issued from the same authorization. Call it when the user disconnects BrandGate in your product.

Redirect URI rules

  • https:// URIs, matched exactly, including the path.
  • http://127.0.0.1, http://[::1] and http://localhost on any port, for native and CLI apps.
  • Private-use schemes such as com.example.app:/callback for mobile apps.

Dynamic client registration

When it is switched on, MCP clients can register themselves (RFC 7591):
Self-registered apps are public clients, get read scopes only, and are marked Not verified for the admin.

Discovery