Skip to main content
Salesive apps authorize with the OAuth 2.1 authorization code flow and PKCE is mandatory (S256). This page walks through the full handshake: redirecting the merchant to consent, receiving an authorization code, and exchanging it for tokens.

Endpoints

Salesive publishes an OAuth 2.1 discovery document. Fetch it once and read the endpoints from it rather than hardcoding paths:
The authorization_endpoint is on the Salesive dashboard host (app.salesive.com) — that’s where the merchant approves. The token_endpoint and all API calls are on the API host (api.salesive.com). Always read these from the discovery document rather than hardcoding.
You’ll need your client_id and client_secret from the Developer console (Apps → Developer). See Build & publish.

Prerequisites

  • A registered app with a client_id, client_secret, and at least one redirect URI.
  • A server endpoint that can receive the OAuth callback and hold the client_secret.
  • The scopes your app needs — see Scopes & permissions.

Step 1 · Generate a PKCE pair

For each install attempt, generate a random code_verifier and derive its code_challenge. Keep the verifier server-side (or in the session) — you’ll need it at token exchange.
PKCE is required. Requests without a valid code_challenge (method S256) are rejected.
Send the merchant’s browser to the authorization_endpoint with your request parameters. The merchant — who is signed in to Salesive — sees a consent screen listing the scopes you requested and the store they’re installing on, then approves.
On approval, Salesive creates the installation on the merchant’s active store and redirects back to your redirect_uri with a code (and your state). On denial, it redirects with ?error=access_denied.

Step 3 · Exchange the code for tokens

From your server, POST to the token_endpoint. Send your client_secret and the PKCE code_verifier you stored in Step 1.
Store the refresh_token securely (encrypted at rest), keyed to the merchant/store. The access_token is short-lived (one hour).
Client credentials may also be sent as HTTP Basic auth (Authorization: Basic base64(client_id:client_secret)) instead of in the body.

Step 3b · Bind your session to the authenticated user

The token response does not include a user id — the access_token is scoped to the installation (store + app), not to an individual Salesive user. This matters when multiple people share access to the same store: if you only bind your session cookie to the store id, a second person who opens the app in the same browser inherits the first person’s session. The fix: immediately after persistTokens, call the default-granted GET /api/v1/app/context endpoint using the token you just stored and embed the returned user.id into your session cookie.
Then, when the Salesive dashboard opens your iframe it appends ?user=<id> to the URL. Read that value and compare it against the session’s stored userId on every request. A mismatch (different Salesive account switched in) means the session is stale — clear the cookie and return authenticated: false so the gate prompts the new user to re-authenticate.
The ?user= value is not a trust signal — it is only used to look up and invalidate the right cookie. The actual authentication proof is always the signed, HttpOnly session cookie.
The Salesive App Starter implements this pattern out of the box in server/session.js (token format), server/routes/oauth.js (userId capture), and server/middleware/requireShop.js (per-request validation). If you copied an earlier version of the starter, update those three files.

Step 4 · Call the API

Send the access token as a bearer token. You do not need to specify the store — the token is already bound to the store it was installed on.
See Scopes & permissions for the full list of endpoints your app can reach and the scope each one requires.

Step 5 · Refresh the access token

When the access token expires, exchange your refresh token for a new pair. Refresh tokens rotate — the old refresh token is invalidated and you receive a new one, so always persist the latest.

Handling uninstalls & revocation

A merchant can uninstall your app at any time from Apps → Installed apps in their dashboard. When they do, the installation is deactivated and all of your app’s tokens for that store stop working immediately — even an access token that hasn’t expired yet. Treat a 401 Unauthorized with a message like “This app is no longer installed on the store” as an uninstall signal: stop calling the API for that store and clean up your stored tokens. You can also proactively revoke a token:

Common errors

Next steps

Scopes & permissions

Map each scope to the endpoints it unlocks.

Build & publish

Register, list, and submit your app for review.