Authentication & scopes
Application access uses OAuth 2.0 client credentials. Each capability has an independent scope.
Client credentials flow#
Send a form-encoded client_credentials request to /oauth/token with HTTP Basic client authentication. Use the returned token as a Bearer token on protected requests. Tokens are opaque; clients must not decode them.
COLLECTALES_ACCESS_TOKEN=$(curl --fail-with-body --silent --show-error \
--request POST "$COLLECTALES_BASE_URL/oauth/token" \
--user "$COLLECTALES_CLIENT_ID:$COLLECTALES_CLIENT_SECRET" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "scope=catalog:read" | jq -er '.access_token')const base = process.env.COLLECTALES_BASE_URL;
const basic = Buffer.from(
`${process.env.COLLECTALES_CLIENT_ID}:${process.env.COLLECTALES_CLIENT_SECRET}`,
).toString("base64");
const tokenResponse = await fetch(`${base}/oauth/token`, {
method: "POST",
headers: {
authorization: `Basic ${basic}`,
"content-type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({ grant_type: "client_credentials", scope: "catalog:read" }),
});
if (!tokenResponse.ok) throw new Error(`Token request failed: ${tokenResponse.status}`);
const { access_token, expires_in } = await tokenResponse.json();import os
import requests
base = os.environ["COLLECTALES_BASE_URL"]
response = requests.post(
f"{base}/oauth/token",
auth=(os.environ["COLLECTALES_CLIENT_ID"], os.environ["COLLECTALES_CLIENT_SECRET"]),
data={"grant_type": "client_credentials", "scope": "catalog:read"},
timeout=10,
)
response.raise_for_status()
access_token = response.json()["access_token"]| Scope | Allows |
|---|---|
catalog:read | Games, cards, and sets |
directories:read | Directory types, entries, and related cards |
prices:read | Current variant-level prices and 7/30-day changes when enabled |
prices:history | Up to six calendar months of daily history (Pro or contract; when enabled) |
decks:read | Published non-tournament decks |
tournaments:read | Events and their tournament deck lists |
meta:read | Sourced leader and archetype representation |
Scope and environment boundaries#
A scope grant authorizes a request; it does not prove that a game has enough data for your use case. Read capability availability separately. Sandbox/staging and production credentials must remain separate.
Token failures#
On protected resources, 401 means the token is invalid, expired, or revoked: obtain one fresh token and retry once. A 403 means the token or plan lacks the required scope. At the token endpoint, invalid credentials return 401 invalid_client; a scope outside the application’s grants returns 400 invalid_scope.