Gallantree Developer API

OAuth 2.0 client credentials

For server-to-server integrations where you'd rather manage a short-lived access token than a long-lived API key, the platform issues JSON Web Tokens via the standard client credentials grant.

Which flow you use is up to you:

Both flows resolve to the same DeveloperAuthContext on the server side. Every scope check, every rate-limit tier, and every audit-log entry behaves identically.

Endpoint

POST /api/auth/oauth/token

Request

The endpoint accepts the standard form encoding, which is what most OAuth client libraries send:

HTTP
POST /api/auth/oauth/token HTTP/1.1
Host: developers.gallantreecapital.com
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=your-app-client-id&client_secret=your-app-client-secret

JSON is also accepted, if that suits your client better:

HTTP
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "your-app-client-id",
  "client_secret": "your-app-client-secret"
}

Client authentication

Credentials can go in the body, as above, or in an HTTP Basic header — the header wins if you send both:

HTTP
Authorization: Basic base64(client_id:client_secret)

Requesting a narrower scope

By default the token carries every scope the app holds. Send scope — space-delimited — to ask for less:

grant_type=client_credentials&client_id=…&client_secret=…&scope=loans:read

Asking for a scope the app does not hold returns 400 invalid_scope; the request is refused rather than quietly trimmed. Narrowing is worth doing when one service only ever reads: a leaked token then carries only what that service needed.

Scopes are re-checked against the app on every request, so a scope removed in the portal stops working immediately — you do not have to wait for the token to expire.

Rate limit

Token requests are limited per client IP, and every attempt counts whether or not the credentials are valid. Exceeding it returns 429 with a Retry-After header. A client needs one token per expiry period, not one per API call — cache the token in memory until it expires. See Rate limits.

Response

JSON
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "loans:read organisations:read"
}

Token responses are returned with Cache-Control: no-store — do not cache them in any shared or on-disk cache.

Using the token

HTTP
GET /api/v1/loans HTTP/1.1
Host: developers.gallantreecapital.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

Send it in Authorization: Bearer … — do not put it in x-api-key. The middleware distinguishes the two.

Choosing between key and JWT

Property API key OAuth JWT
Lifetime 90 days (default) 15 minutes
Rotation Manual — generate a new key, retire the old within a 24h grace window Automatic — request a fresh token when the current one expires
Storage Secret store; grep-safe prefix gt_ Ephemeral — hold in memory only
Best for Long-lived integrations, CLIs, batch jobs Frequent-request services that want short-lived credentials
Compromise blast radius Up to 90 days if you don't detect it Up to 15 minutes if you don't detect it

For most integrations, API keys are fine. Reach for OAuth when the token blast radius matters more than the request overhead.

Runnable example

Shell
# 1. Get a token
TOKEN=$(curl -sS https://developers.gallantreecapital.com/api/auth/oauth/token \
  -H "Content-Type: application/json" \
  -d "{
    \"grant_type\": \"client_credentials\",
    \"client_id\": \"$GALLANTREE_CLIENT_ID\",
    \"client_secret\": \"$GALLANTREE_CLIENT_SECRET\"
  }" | jq -r .access_token)

# 2. Use it
curl -sS https://developers.gallantreecapital.com/api/v1/loans \
  -H "Authorization: Bearer $TOKEN"
Was this page helpful?

Built with Token Gesture