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).
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 randomcode_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 yourredirect_uri:
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.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.scope to narrow the new access token.
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):Redirect URI rules
https://URIs, matched exactly, including the path.http://127.0.0.1,http://[::1]andhttp://localhoston any port, for native and CLI apps.- Private-use schemes such as
com.example.app:/callbackfor mobile apps.