An API key is how a wholesaler’s own systems sign in. A software vendor whose product serves many wholesalers, such as a billing tool or a CRM, registers an OAuth app instead. Each wholesaler connects it with a “Connect to Check Networks” button in the vendor’s product, approves what it may do, and 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 the app’s name, your company and a
contact email, the redirect URIs it sends people back to, and the scopes
it may ask for. Redirect URIs are absolute https addresses with no
fragment, and 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 one 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. A disabled app’s tokens stop
working for every account at once, with app_disabled. The app gets a
client id and a client secret. The secret is shown 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 is sent back asinvalid_scope. -
The person signs in and approves. Only an Owner or Admin can approve, and only one who could put every scope asked for on an API key:
account:create,account:updateandaccount:deleteneed an Owner. Anyone else sees why and can only deny. Denying sends them back witherror=access_denied. The account’s Owners are emailed when an app is connected. -
Exchange the code within ten minutes at
POST /oauth/tokenon the API host, withgrant_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, as with a key’s. 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 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. One left idle for longer has to be connected again by the account.
Within 60 seconds of the refresh that replaced it, a used refresh token is
taken as a retry: 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 first refresh returned. They cannot be sent
again.
After 60 seconds we treat it as a stolen copy. The refresh is refused, the
app is disconnected from that account with all its tokens, which are then
refused with app_access_revoked, and the account’s Owners are emailed to
connect it again. If your app runs more than one process, make sure only
one refreshes 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, and the account’s own limit applies across 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, and your
production client id works only in production. Asking again replaces 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.
Connected Apps
Company Settings, then Integrations, then Connected Apps lists every app
the account has connected: its name and maker, the scopes it may use, who
approved it and when. Revoke ends its access at once. Its access tokens
are refused on their next call with app_access_revoked, and so is its
refresh token. To use it again, connect it again. Connecting an app that is
already connected replaces the old access, and the tokens from before stop
working.
Only an Owner or Admin who could grant what an app holds can revoke it, as for an API key.