Skip to content
gist.link ↗

Authentication

All GistLink APIs authenticate with a Bearer access token minted by the auth service. Programmatic integrations obtain tokens by exchanging an IAM API key through the standard OAuth 2.0 client_credentials grant (RFC 6749 §4.4).

POST https://auth.api.gist.link/oauth/token

The endpoint accepts either application/x-www-form-urlencoded or application/json bodies. Client credentials may be sent in the body (client_id / client_secret) or as HTTP Basic authentication (RFC 6749 §2.3.1) — both are equivalent.

Parameter Required Description
grant_type Yes Must be client_credentials.
client_id Yes* Your IAM key id (gciam_…). Or send both credentials via HTTP Basic.
client_secret Yes* Your IAM key secret (gcsk_…).
audience Yes The product the token is for — its service key, e.g. support, pay, mail. suite and auth are rejected for IAM credentials.
scope No Space-separated permissions to narrow the token below the key’s grants. You can only narrow — requesting anything the key doesn’t hold fails with invalid_scope.
Terminal window
curl https://auth.api.gist.link/oauth/token \
-u 'gciam_your_key_id:gcsk_your_secret' \
-d grant_type=client_credentials \
-d audience=pay \
-d 'scope=pay:query:invoices pay:query:invoice'
{
"access_token": "eyJhbGciOiJSUzI1NiIs…",
"token_type": "Bearer",
"expires_in": 900,
"scope": "pay:query:invoices pay:query:invoice"
}
Field Description
access_token An RS256-signed JWT. Send it as Authorization: Bearer <token> on GraphQL requests.
token_type Always Bearer.
expires_in Lifetime in seconds (15 minutes by default).
scope The token’s effective permissions: the intersection of the key’s grants, its parent IAM user’s current grants, any scope narrowing you requested — filtered to the requested audience.

IAM exchanges never include a refresh_token. When a token expires, perform the exchange again — it’s a single fast request, and it’s how permission changes and key revocations take effect.

You don’t need to decode the JWT to use it, but the claims are useful for debugging:

Claim Meaning
sub The IAM user’s UUID.
org Your organization’s UUID — every API call is scoped to it.
aud The single product audience you requested (e.g. pay).
roles ["ROLE_IAM", "ROLE_USER", "ROLE_ADMIN"] for IAM tokens.
permissions The effective permission list (mirrored into scope).
principal_type iam_user.
api_key_id The credential’s UUID, for audit correlation.
iat / exp / jti Issued-at, expiry, and a unique token id.

A token minted for audience=support is rejected by every other API. Calling three products means holding three tokens. This is deliberate: a leaked token compromises at most one product for at most its remaining lifetime, bounded by the key’s granted permissions.

The audience must be a known product key — see the API reference for the full catalog. IAM credentials cannot request suite (the multi-app human-session audience) or auth (identity management stays with human administrators).

  • Rotation — rotating a key (Settings → Security → IAM users) invalidates the old secret immediately and prints a new one-time secret.
  • Revocation — revoking a key, disabling its IAM user, or removing a permission blocks new token exchanges immediately. Already-issued tokens remain valid until they expire (minutes). Use rotation + the short TTL as your revocation window.
  • Narrowed grants — updating the IAM user’s permissions takes effect on the next exchange of any of its keys; a key’s effective permissions can never exceed its parent user’s current grants.

Errors follow RFC 6749 ({"error": "…", "error_description": "…"}); see Errors & rate limits for the full table. The three you’ll hit most while integrating:

error Likely cause
invalid_client Wrong key id/secret, or the key was revoked/expired/disabled.
invalid_target Missing or unknown audience, or you requested suite/auth.
invalid_scope Your scope narrowing asked for something the key doesn’t hold, or the key has no grants for the requested audience.