Skip to main content
Once you have created an API Client in Keycloak, use your credentials to obtain an access token.
Best for Automation Use Machine-to-Machine (M2M) authentication for CI/CD pipelines (Jenkins, GitHub Actions) and background services. This method supports zero-downtime credential rotation.
M2M tokens aren’t subject to role-based access control. A token from any API client has full administrative access to every product, image, ruleset and team in your organization. Protect the client secret accordingly. See Access control for M2M tokens.

Prerequisites

You need the client_id and client_secret from your API Client Setup.

Request Token

Use the Client Credentials Grant flow to exchange your ID and Secret for a Bearer token.

Response

The API returns a JSON object containing your access_token.

Using the Token

Include the token in the Authorization header when making API requests: Authorization: Bearer <access_token> The examples on the API reference pages read the token from TOKEN and your dashboard URL from BINARLY_API_URL. Set both before you run them:
Note: Tokens expire after 30 minutes. Your automation should request a fresh token before each job or handle 401 Unauthorized errors by refreshing credentials.