PPylon Developers

Authentication

How to authenticate requests to the Pylon API.

Pylon has two kinds of credential: a person's token for the admin and organizer API, and an API key for a machine that pushes items into the pool.

People: JWT bearer tokens

Requests to /api/v1/* and /api/organizer/v1/* carry a bearer token:

GET /api/v1/me HTTP/1.1
Host: api.pylon.pt
Authorization: Bearer <jwt>

Tokens come from the Pylon auth server through the OAuth 2.0 authorization code flow. See the Auth tag in the API reference.

Machines: API keys

An API key belongs to one account. An account owner or admin creates it in the admin under Settings → API, or with POST /api/organizer/v1/api-clients:

POST /api/organizer/v1/api-clients HTTP/1.1
Authorization: Bearer <jwt>
X-Pylon-Account-Id: <account id>
Content-Type: application/json

{ "name": "Agenda feed", "role": "api.pool-publisher" }

The answer carries the secret once:

{
  "key": { "id": "…", "name": "Agenda feed", "keyPrefix": "pyk_live_AbC123dEf456", "role": "api.pool-publisher",
           "status": "Active", "createdAt": "…", "lastUsedAt": null, "revokedAt": null },
  "secret": "pyk_live_AbC123dEf456…"
}
  • Keep the secret. Pylon stores only its prefix and a SHA-256 hash, so it cannot show it again. Lose it and you create a new key.
  • The role limits the key. api.pool-publisher may only push items to the sources its account owns.
  • Use it as a bearer token on the partner routes, /api/partner/v1/*:
POST /api/partner/v1/sources/<source id>/items HTTP/1.1
Authorization: Bearer pyk_live_…
  • Revoke with POST /api/organizer/v1/api-clients/<id>/revoke. A revoked key fails at once with 401.

A missing, unknown or revoked key answers 401; a key whose role does not allow the call answers 403.

See Pushing items for the push routes.

On this page