Skip to main content

Authentication

Kynasmith uses short-lived bearer access tokens for API calls. The SDKs handle token management for you.

Server-side authentication

Use your project-bound API key to initialize the Python SDK. The SDK automatically exchanges your credentials for a short-lived access token and refreshes it as needed.
The api_key value combines your key ID and secret in the format key_id:key_secret. You can find both values in the portal under Settings > API Keys.
You can also bootstrap with separate key ID and secret fields, or with a service account:

Browser authentication

Do not embed long-lived API keys or service-account secrets in the browser. Instead, expose a backend endpoint that exchanges your API key for a short-lived Kynasmith access token, then pass it through a tokenProvider:

Backend token endpoint example

Your backend endpoint should call the Kynasmith token exchange API:
The response contains an access_token field with the short-lived bearer token your frontend needs.
If you already have a short-lived bearer token, you can pass it directly instead of a tokenProvider:
When using a static accessToken, you are responsible for refresh and rotation.

Access token scopes

When minting an access token, you can restrict its capabilities with scopes. If no scopes are specified, the token inherits the full scope of the credential that minted it. Use the narrowest scope set that your integration requires. Browser integrations typically need only sessions:write (and optionally movespecs:read).

Token lifetime notes

  • Browser integrations should treat tokenProvider as a refresh hook, not as one-time bootstrap. The SDK may call it before each authenticated request.
  • The Python SDK automatically refreshes access tokens as they approach expiry.
  • If you pass a bearer token directly through accessToken or access_token, you are responsible for refresh and rotation.

Direct API integration

If you are integrating without an official SDK, use:
  1. POST /api/auth/access-tokens to mint a bearer access token
  2. Authorization: Bearer <access_token> header on all subsequent API calls
  3. POST /api/detection/sessions to create a session
See the API reference for the full endpoint documentation. If token exchange, scopes, or bearer auth fail, see Authentication troubleshooting.