Skip to main content
All GraphQL requests to the Pylon API require authentication using OAuth Bearer tokens.

Authentication header

Include your access token in the Authorization header:

Making authenticated requests

Using fetch

Using GraphQL client

Most GraphQL clients support setting default headers:

Getting access tokens

Access tokens are obtained through the OAuth 2.0 client credentials grant. See the Authentication guide for details on:
  • Obtaining client credentials
  • Exchanging credentials for tokens
  • Requesting a new token when the cached one expires

Token expiration

Access tokens are issued with a fixed lifetime (roughly 24 hours). There is no refresh-token grant β€” when a token expires you simply request a brand-new one from the token endpoint using the same client credentials. Cache the token along with its expiry and re-request when it’s expired:

Error responses

Unauthenticated requests return:

Best practices

  1. Store credentials securely - Never expose your client secret or tokens in client-side code
  2. Cache tokens and re-request before expiry - Reuse a cached token until it expires, then request a new one
  3. Handle errors gracefully - Surface authentication failures clearly
  4. Use HTTPS - Always use HTTPS in production
  5. Rotate credentials - Regularly rotate your client credentials for security