Skip to main content
An app is something you build that other sellers connect to their own stores: a stock sync, an accounting export, a Discord bot. A seller connects it with two presses on a Shoply page, and your app is handed a token that works like an API key of their store. Your own store needs none of this. For your own server, make an API key.

How it works

  1. You send the seller to Shoply’s approval page with your app’s client ID.
  2. They pick one of their stores and press Allow Access. Shoply sends them back to your app with a code.
  3. Your server swaps the code for a token.
  4. The token is a key of their store, with the permissions your app asked for, until they disconnect your app.
This is OAuth 2.0’s authorization code flow, with PKCE. Any OAuth library that takes an authorization address and a token address works with it.

Make an app

In the dashboard, open Developers, OAuth Apps, then Your Apps, and press Add App. Adding it shows its Client ID and Client Secret. The client ID is not a secret: it is in the address sellers are sent to. The client secret is shown this once. Keep it on your server, never in a page or an app people can download. If you lose it, New Client Secret in the app’s menu replaces it, and the old one stops working at once. An account can make up to 10 apps. Any seller can connect any of them. Shoply does not review apps, and the approval page says so.

1. Send the seller to approve it

The seller signs in if they need to, picks one of their stores, and sees your app’s name, logo, maker, website and every permission it asks for. Allow Access asks them to confirm it is them, as making an API key does. Only a store’s owner can approve. If your client ID does not exist, or the redirect URL is not one of your app’s, the page says so and sends the seller nowhere.

2. The seller comes back

Approved, they come back to your redirect URL with a code and your state:
Cancelled, or with something wrong in what you sent, they come back with error and your state instead: error_description says it in a sentence.

3. Swap the code for a token

From your server, within 10 minutes, once:
The client ID and secret go by HTTP Basic, or as client_id and client_secret in the body. The body may be a form or JSON. With PKCE, send code_verifier too. A desktop or phone app sends client_id and code_verifier, and no secret.
These answers are OAuth’s own shape, not the API’s success and data. A refusal is error and error_description: A code offered a second time is taken as one somebody else saw on its way, and the token it was swapped for stops working too.

4. Use the token

The token is a key of the seller’s store. Send it as any key is sent: Authorization: Bearer shoply_at_....
  • It reaches what the seller approved and nothing more. A route that needs another permission is refused with missing_scope.
  • It works from anywhere, with no last day, until the seller disconnects your app.
  • Get the current key answers the store it is for, and app, your app. Everything a key is held to holds for it: its rate limits, and the store’s record of requests, where it is named after your app.
  • What only the dashboard does, behind “Confirm it’s you”, no token does.
A seller who approves your app again for the same store replaces its token: the old one stops, and the webhook endpoints it made carry over to the new one.

PKCE, and apps on a computer or phone

A desktop or phone app cannot keep a secret: anybody with a copy can read one out of it. So it has none, and proves the code is its own with PKCE instead:
  1. Make a verifier, 43 to 128 letters, digits and -._~, and keep it.
  2. Send its challenge, the base64url of its SHA-256 with no padding, as code_challenge, with code_challenge_method=S256.
  3. Send the verifier as code_verifier with the code.
A desktop app usually listens on this computer for the seller to come back. Add http://127.0.0.1/callback as a redirect URL, and send http://127.0.0.1:<any port>/callback: the port is yours to pick each time. The address and path must match. A web app may use PKCE as well as its secret. When it sends a challenge, the verifier is asked for too.

When a seller disconnects

A seller sees every app connected to a store under Developers, OAuth Apps, Connected, with what it may do and when it was last used, and ends one with Disconnect. Then:
  • Its token stops working at once.
  • The webhook endpoints it made with its token are deleted. The store’s own endpoints stay.
  • The store’s own server gets app.disconnected, as it got app.connected. See Webhook events.
  • Your app is told, if it has an address under Disconnect Notices.
The notice is a POST in a webhook’s shape, signed as a webhook is, with your app’s notice secret (shown once when you add the address, and replaced with New Notice Secret):
Check it as you would a webhook: webhooks.verify in the SDKs takes the notice secret. reason is seller, or code_reused when Shoply ended it because its code was offered twice. A notice your server does not answer with a 2xx is tried again for about a day. To give a token up yourself, when a seller removes your app on your side:
It answers 200 whether or not there was such a token. Deleting an app disconnects it from every store.

With the SDKs

The server SDKs take a token as their key, and have the four steps:
A refusal from the token address is the SDK’s error, with OAuth’s word as its code: invalid_grant, invalid_client.

Limits