A wholesaler’s own systems sign in with an API key. If your product serves many wholesalers, such as a billing tool or a CRM, you register an OAuth app instead. Each wholesaler connects it with a “Connect to Check Networks” button in your product and approves what it may do. They can revoke it later. Nobody copies a key from one system to another.
Registering an app
Only integrators Check Networks has vetted have an app, and we register it for you. Contact Check Networks with:
| Detail | What to send |
|---|---|
| Name | The app’s name. |
| Company | Your company and a contact email. |
| Redirect URIs | The addresses it sends people back to. |
| Scopes | The scopes it may ask for. |
Redirect URIs are absolute https addresses with no fragment. The one an app
sends must match a registered one exactly. While you build, you can also
register http://localhost and http://127.0.0.1 addresses, on any port. A
127.0.0.1 address matches whatever port the app sends. A localhost
address must match its port too.
An app never gets the safety:read or safety:update scopes. They stay
with the wholesaler’s own API keys.
A new app starts pending. Check Networks approves it before any wholesaler
can connect it, and can disable it later. When an app is disabled, its tokens
stop working for every account at once, with app_disabled. The app gets a
client id and a client secret. We show the secret once.
Connecting an account
The flow is the OAuth 2.0 authorization code grant with PKCE.
-
Send the person to the consent screen, on the wholesale portal:
https://checknetworks.tools/oauth/authorize ?response_type=code &client_id=<your client id> &redirect_uri=<a registered redirect URI> &scope=<space-separated scopes> &state=<a value you check on the way back> &code_challenge=<BASE64URL(SHA256(code_verifier))> &code_challenge_method=S256PKCE is required, and only
S256. The scopes must be within the ones the app may ask for. Anything else comes back asinvalid_scope. -
The person signs in and approves. Only an Owner or Admin can approve. They must also be someone who could put every scope asked for on an API key, so
account:create,account:updateandaccount:deleteneed an Owner. Anyone else sees why and can only deny. Denying sends them back witherror=access_denied. We email the account’s Owners when an app is connected. -
Exchange the code within ten minutes at
POST /oauth/tokenon the API host. Sendgrant_type=authorization_code, thecode, the sameredirect_uri, thecode_verifier, and yourclient_idandclient_secret. A wrong verifier is refused withinvalid_grant. -
Call the API with the access token, the same way as with a key. It acts for the account that approved it, within the scopes approved, whoever approved it.
GET /pingshows the account and the scopes.
Tokens
An access token lasts one hour. Refresh it at POST /oauth/token with
grant_type=refresh_token, the refresh_token, and your client_id and
client_secret. Every refresh gives you a new access token and a new
refresh token. Store the new refresh token, because the old one is refused
from then on.
A refresh token lasts 30 days from the refresh that issued it. An app that refreshes at least once every 30 days stays connected. If it sits idle for longer, the account has to connect it again.
Within 60 seconds of the refresh that replaced it, we take a used refresh
token as a retry. That covers a lost response, or two processes refreshing at
once. The refresh is refused with temporarily_unavailable, and the app
stays connected. Use the tokens that the first refresh returned. They can’t
be sent again.
After 60 seconds we treat it as a stolen copy and refuse the refresh. We
disconnect the app from that account with all its tokens, which are then
refused with app_access_revoked. We email the account’s Owners to connect
it again. If your app runs more than one process, let only one refresh at a
time. Every refused refresh is on the account’s audit trail.
Each app has its own rate limit for each account it is connected to. The account’s own limit applies across all its keys and apps.
Testing on the sandbox
Ask Check Networks for a sandbox copy of your app. It has the same redirect
URIs and scopes, but its own client id and a secret that starts cn_test_,
shown once. It works only on the sandbox. Your production
client id works only in production. If you ask again, we replace the copy,
and the old copy’s secret and tokens stop working.
Test the whole flow against a sandbox account. A wholesaler with a sandbox,
or your own test account, signs in to the sandbox portal with Open
Sandbox. Your app sends them to
https://portal.checknetworks.dev/oauth/authorize and exchanges the code at
https://api.checknetworks.dev/v2/oauth/token. Everything else works as in
production, except that the sandbox sends no email.
When an account revokes the app
A wholesaler sees every app it has connected under Company Settings, then
Integrations, then Connected Apps. They can revoke one there at any time.
The app’s access tokens are then refused on their next call with
app_access_revoked, and so is its refresh token. Ask the account to
connect it again. Connected apps
in the portal’s help covers the wholesaler’s side.