Skip to main content
The full path to calling APIs with user consent. Before you start, register an OAuth client app in the developer console and have your App Key, secret key, and redirect URI ready. Your App Key and secret key are the client_id and client_secret in OAuth terms.
1

Generate PKCE values

Generate these fresh for every request. Only S256 is accepted; plain is rejected.
Keep the verifier in the session (or alongside state) and send it in step 3. If it falls outside the spec — 43 to 128 characters, allowed character set — the token exchange fails with invalid_grant.
2

Send the user to the consent screen

Redirect the user’s browser to this address.
Line breaks are for readability — send it as a single line with no whitespace.After the user signs in and grants consent, they return to your registered redirect URI.
Always verify that state matches what you sent — without this you are open to CSRF. And check for an error parameter as well as code: a user who declines comes back with error.
3

Exchange the code for a token

Call this from your server. Calling it from a browser exposes your secret key.
The redirect_uri must be character-for-character identical to the one in step 2. The code is valid for 5 minutes and can be used once.
4

Call the API with the token

User-context /api/v1/** calls work the same way.

Refreshing tokens

Access tokens expire after 15 minutes.
The response carries a new refresh_token. Store it and discard the old one. Refresh tokens rotate on every use, so a repeat request with the old value fails.

Disconnecting

When a user asks to disconnect, revoke the token.

Common errors

For safety, a failed redirect URI check shows the user a 400 page and never redirects to an unregistered address.

Before you go to production

  • Never put your secret key in a browser or mobile app bundle. Exchange tokens on the server.
  • Generate state per request and verify it in the callback.
  • Store refresh tokens per user, and overwrite with the new value on every refresh.
  • When a user disconnects, revoke and delete the stored tokens.