Exchange an API client ID and secret for a Bearer token with the client credentials grant.
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.
# 1. Set your credentials (export them in your shell or CI/CD env)export BINARLY_CLIENT_ID="your-client-id"export BINARLY_CLIENT_SECRET="your-client-secret"# Replace {slug} with your organization's tenant identifierexport BINARLY_AUTH_URL="https://auth-{slug}.binarly.cloud/realms/BinarlyRealm/protocol/openid-connect/token"# 2. Request the tokencurl -s --fail-with-body \ -H "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "grant_type=client_credentials" \ --data-urlencode "client_id=${BINARLY_CLIENT_ID}" \ --data-urlencode "client_secret=${BINARLY_CLIENT_SECRET}" \ "${BINARLY_AUTH_URL}"
Response
The API returns a JSON object containing your access_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.
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Binarly Transparency Platform","colors":{"primary":"#938aff","dark":"#3f3b6c"},"logo":{"light":"https://mintcdn.com/binarly-bee2cf27/F4uiXSPVpYbvs_1l/assets/logo/binarly_light.svg?fit=max\u0026auto=format\u0026n=F4uiXSPVpYbvs_1l\u0026q=85\u0026s=869fa19c4b6da10775d7d4a1264ee89a","dark":"https://mintcdn.com/binarly-bee2cf27/F4uiXSPVpYbvs_1l/assets/logo/binarly_dark.svg?fit=max\u0026auto=format\u0026n=F4uiXSPVpYbvs_1l\u0026q=85\u0026s=479b5ab702ac9a82b1588994a916f198","href":"https://binarly.io"},"favicon":"https://mintcdn.com/binarly-bee2cf27/i0nENN1ygFAR0dXP/assets/favicon.png?fit=max\u0026auto=format\u0026n=i0nENN1ygFAR0dXP\u0026q=85\u0026s=92d37b47a27223da72be8f7ca130cdd0","appearance":{"default":"light","strict":true},"background":{"decoration":"gradient"},"footer":{"socials":{"youtube":"https://www.youtube.com/@binarly","x":"https://x.com/binarly_io","github":"https://github.com/binarly-io","linkedin":"https://www.linkedin.com/company/binarlyinc"}},"fonts":{"family":"Exo 2"},"contextual":{"options":["mcp","add-mcp","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Free Scanner","icon":"barcode-read","href":"https://risk.binarly.io"},{"anchor":"VulHunt","icon":"bug","href":"https://vulhunt.re"},{"anchor":"Github","icon":"github","href":"https://github.com/binarly-io/"},{"anchor":"Advisories","icon":"book-open-cover","href":"https://www.binarly.io/advisories"},{"anchor":"Product Blog","icon":"newspaper","href":"https://www.binarly.io/blog"},{"anchor":"Research Blog","icon":"newspaper","href":"https://www.binarly.io/articles"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"binarly-bee2cf27","hasAudioNarration":false,"actualSubdomain":"binarly-bee2cf27","customDomains":["docs.binarly.io"],"gitSource":{"type":"github","owner":"binarly-io","repo":"binarly-product-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"issues":true,"edits":true,"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af5ce46c7a2465f2886af5a","clientVersion":"0.0.4142","searchFilterCounts":[{"language":"default","tag":"Release Notes","count":81},{"language":"default","tag":"User Guides","count":40},{"language":"default","tag":"API","count":32},{"language":"default","tag":"Resource Center","count":22},{"language":"default","tag":"Reference","count":16},{"language":"default","tag":"On-Prem","count":10},{"language":"default","tag":"Installation","count":10},{"language":"default","tag":"Exploring Image Scans","count":10},{"language":"default","tag":"Overview","count":9},{"language":"default","tag":"Use Cases","count":8}]},"assistantConfig":{"enableStarterQuestions":false,"deflection":{"enabled":true,"email":"support@binarly.io","showHelpButton":true}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[],"page":{"pagePath":"api-reference/authentication/get-m2m-token","slug":"/api-reference/authentication/get-m2m-token","pageMetadata":{"title":"M2M Authentication","description":"Exchange an API client ID and secret for a Bearer token with the client credentials grant.","public":true,"href":"/api-reference/authentication/get-m2m-token"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,blockquote:`blockquote`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Once you have created an API Client in Keycloak, use your credentials to obtain an access token.`}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Best for Automation`}),` Use Machine-to-Machine (M2M) authentication for `,_jsx(_components.strong,{children:`CI/CD pipelines`}),` (Jenkins, GitHub Actions) and background services. This method supports zero-downtime credential rotation.`]})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`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 `,_jsx(_components.a,{href:`/api-reference/authentication/overview#access-control-for-m2m-tokens`,children:`Access control for M2M tokens`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.p,{children:[`You need the `,_jsx(_components.code,{children:`client_id`}),` and `,_jsx(_components.code,{children:`client_secret`}),` from your `,_jsx(_components.a,{href:`/api-reference/authentication/create-api-client`,children:`API Client Setup`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`request-token`,children:`Request Token`}),`\n`,_jsx(_components.p,{children:`Use the Client Credentials Grant flow to exchange your ID and Secret for a Bearer token.`}),`\n`,_jsx(CodeGroup,{children:_jsx(CodeBlock,{filename:`Request`,numberOfLines:`13`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`13`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 1. Set your credentials (export them in your shell or CI/CD env)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` BINARLY_CLIENT_ID`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your-client-id\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` BINARLY_CLIENT_SECRET`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your-client-secret\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Replace {slug} with your organization's tenant identifier`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` BINARLY_AUTH_URL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://auth-{slug}.binarly.cloud/realms/BinarlyRealm/protocol/openid-connect/token\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# 2. Request the token`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -s`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --fail-with-body`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/x-www-form-urlencoded\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"grant_type=client_credentials\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"client_id=${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_CLIENT_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"client_secret=${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_CLIENT_SECRET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_AUTH_URL`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`})]}),`\n`]})})})}),`\n`,_jsx(Heading,{level:`3`,id:`response`,children:`Response`}),`\n`,_jsxs(_components.p,{children:[`The API returns a JSON object containing your `,_jsx(_components.code,{children:`access_token`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"access_token\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"eyJhbGciOiJSUzI1NiIs...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"token_type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Bearer\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"expires_in\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1800`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`using-the-token`,children:`Using the Token`}),`\n`,_jsxs(_components.p,{children:[`Include the token in the `,_jsx(_components.code,{children:`Authorization`}),` header when making API requests:`]}),`\n`,_jsx(_components.p,{children:_jsx(_components.code,{children:`Authorization: Bearer \u003caccess_token>`})}),`\n`,_jsxs(_components.p,{children:[`The examples on the API reference pages read the token from `,_jsx(_components.code,{children:`TOKEN`}),` and your dashboard URL from `,_jsx(_components.code,{children:`BINARLY_API_URL`}),`. Set both before you run them:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`TOKEN`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`$(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -sS`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --fail-with-body`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/x-www-form-urlencoded\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"grant_type=client_credentials\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"client_id=${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_CLIENT_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --data-urlencode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"client_secret=${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_CLIENT_SECRET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:' \"${'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`BINARLY_AUTH_URL`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:` jq`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -r`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '.access_token'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Replace {slug} with your organization's tenant identifier. Endpoint paths add /api/v4.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` BINARLY_API_URL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://dashboard-{slug}.binarly.cloud\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.blockquote,{children:[`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Note`}),`: Tokens expire after 30 minutes. Your automation should request a fresh token before each job or handle `,_jsx(_components.code,{children:`401 Unauthorized`}),` errors by refreshing credentials.`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"M2M Authentication","description":"Exchange an API client ID and secret for a Bearer token with the client credentials grant.","public":true,"href":"/api-reference/authentication/get-m2m-token"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Request Token","slug":"request-token","depth":2,"children":[{"title":"Response","slug":"response","depth":3,"children":[]}]},{"title":"Using the Token","slug":"using-the-token","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"binarly-bee2cf27","siteName":"Binarly Transparency Platform","title":"M2M Authentication - Binarly Transparency Platform","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-29T11:23:33.185Z","originalFileLocation":"api-reference/authentication/get-m2m-token.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"light\";if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Binarly Transparency Platform\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"M2M Authentication - Binarly Transparency Platform\">\u003cmeta data-mint-head property=\"og:description\" content=\"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Binarly Transparency Platform\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.binarly.io/api-reference/authentication/get-m2m-token\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://binarly-bee2cf27.mintlify.site/_mintlify/api/og/v2?division=Authentication\u0026amp;title=M2M+Authentication\u0026amp;description=Exchange+an+API+client+ID+and+secret+for+a+Bearer+token+with+the+client+credentials+grant.\u0026amp;theme=a4bf61fed8dc0e5bab0176d3\u0026amp;signature=2df4be3870ebf3dc26e9316a8e53e2165fe719fb7d2eea138d2bf1b412983290\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"M2M Authentication - Binarly Transparency Platform\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://binarly-bee2cf27.mintlify.site/_mintlify/api/og/v2?division=Authentication\u0026amp;title=M2M+Authentication\u0026amp;description=Exchange+an+API+client+ID+and+secret+for+a+Bearer+token+with+the+client+credentials+grant.\u0026amp;theme=a4bf61fed8dc0e5bab0176d3\u0026amp;signature=2df4be3870ebf3dc26e9316a8e53e2165fe719fb7d2eea138d2bf1b412983290\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/binarly-bee2cf27/5yqOd4cyIuKdgXEG/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Binarly Transparency Platform\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#938aff\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.binarly.io/api-reference/authentication/get-m2m-token\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/authentication/get-m2m-token.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.binarly.io/#organization\",\"name\":\"Binarly Transparency Platform\",\"url\":\"https://docs.binarly.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/binarly-bee2cf27/F4uiXSPVpYbvs_1l/assets/logo/binarly_light.svg?fit=max\u0026auto=format\u0026n=F4uiXSPVpYbvs_1l\u0026q=85\u0026s=869fa19c4b6da10775d7d4a1264ee89a\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.binarly.io#website\",\"name\":\"Binarly Transparency Platform\",\"url\":\"https://docs.binarly.io\",\"publisher\":{\"@id\":\"https://docs.binarly.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token#webpage\",\"url\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token\",\"name\":\"M2M Authentication\",\"description\":\"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\",\"dateModified\":\"2026-10-29T11:23:33.185Z\",\"isPartOf\":{\"@id\":\"https://docs.binarly.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Overview\",\"item\":\"https://docs.binarly.io/api-reference/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Authentication\",\"item\":\"https://docs.binarly.io/api-reference/authentication/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"M2M Authentication\",\"item\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token#article\",\"headline\":\"M2M Authentication\",\"name\":\"M2M Authentication\",\"description\":\"Exchange an API client ID and secret for a Bearer token with the client credentials grant.\",\"url\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token\",\"mainEntityOfPage\":{\"@id\":\"https://docs.binarly.io/api-reference/authentication/get-m2m-token#webpage\"},\"dateModified\":\"2026-10-29T11:23:33.185Z\",\"publisher\":{\"@id\":\"https://docs.binarly.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.binarly.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Binarly Transparency Platform\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Binarly Transparency Platform\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/authentication/get-m2m-token.md","siteName":"Binarly Transparency Platform","nav":{"global":{"anchors":[{"anchor":"Free Scanner","icon":"barcode-read","href":"https://risk.binarly.io"},{"anchor":"VulHunt","icon":"bug","href":"https://vulhunt.re"},{"anchor":"Github","icon":"github","href":"https://github.com/binarly-io/"},{"anchor":"Advisories","icon":"book-open-cover","href":"https://www.binarly.io/advisories"},{"anchor":"Product Blog","icon":"newspaper","href":"https://www.binarly.io/blog"},{"anchor":"Research Blog","icon":"newspaper","href":"https://www.binarly.io/articles"}]},"tabs":[{"tab":"User Guides","pages":[{"title":"User Guides","href":"/user-guides/about/why"}]},{"tab":"Resource Center","pages":[{"title":"Resource Center","href":"/resource-center/vulnerability-detection"}]},{"tab":"Release Notes","pages":[{"title":"Release Notes","href":"/release-notes/release-cadence"}]},{"tab":"API","groups":[{"group":"Overview","pages":[{"title":"Get Started","href":"/api-reference/introduction"},{"group":"Authentication","pages":[{"title":"Authentication Methods","href":"/api-reference/authentication/overview"},{"title":"Setup API Client","description":"Get an API client ID and secret for machine-to-machine access, from Binarly support on SaaS or in Keycloak on-premises.","href":"/api-reference/authentication/create-api-client"},{"title":"M2M Authentication","public":true,"href":"/api-reference/authentication/get-m2m-token"},{"title":"User Authentication","description":"Get a Bearer token with your Binarly user email and password for ad-hoc API requests.","href":"/api-reference/authentication/generate-token"}]},{"group":"Deployment","pages":[{"title":"SaaS API Considerations","href":"/api-reference/deployment/saas-considerations"},{"title":"On-Prem API Considerations","href":"/api-reference/deployment/onprem-considerations"}]},{"title":"Troubleshooting","href":"/api-reference/troubleshooting"}]},{"group":"Use Cases","pages":[{"group":"CI/CD Integration","pages":[{"title":"Overview","href":"/api-reference/use-cases/cicd/overview"},{"title":"Bash Script","href":"/api-reference/use-cases/cicd/bash"},{"title":"GitHub Actions","href":"/api-reference/use-cases/cicd/github-actions"},{"title":"Jenkins Pipeline","href":"/api-reference/use-cases/cicd/jenkins"},{"title":"GitLab CI","href":"/api-reference/use-cases/cicd/gitlab-ci"},{"title":"Verify Results","href":"/api-reference/use-cases/cicd/verify-results"}]},{"title":"Triage \u0026 Analysis","href":"/api-reference/use-cases/triage-and-analysis"},{"title":"Compliance Artifacts","href":"/api-reference/use-cases/compliance-artifacts"}]},{"group":"Reference","pages":[{"group":"Products","pages":[{"title":"List Products","href":"/api-reference/product/list-products"},{"title":"Get Product","href":"/api-reference/product/get-product"},{"title":"Create Product","href":"/api-reference/product/create-product"}]},{"group":"Images","pages":[{"title":"List Images","href":"/api-reference/image/list-images"},{"title":"Get Image","href":"/api-reference/image/get-image"},{"title":"Upload Image","href":"/api-reference/image/upload-image"},{"title":"Upload Debug Symbols","href":"/api-reference/file/create-file-attachment"}]},{"group":"Scans","pages":[{"title":"Get Scan","href":"/api-reference/scan/get-scan"},{"title":"List Components","href":"/api-reference/scan/scan-components"},{"title":"List Scans","href":"/api-reference/scan/list-scans"}]},{"group":"Reports","pages":[{"title":"SBOM Reports","href":"/api-reference/report/sbom-report"},{"title":"VEX Reports","href":"/api-reference/report/vex-report"},{"title":"CBOM Reports","href":"/api-reference/report/cbom-report"},{"title":"PQC Compliance Report","href":"/api-reference/report/pqc-report"},{"title":"Findings Report","href":"/api-reference/report/findings-report"}]},{"group":"Findings","pages":[{"title":"Compare Findings","href":"/api-reference/finding/compare-findings"}]}]}]},{"tab":"On-Prem","menu":[{"item":"Binarly v3","pages":[{"title":"Binarly v3","href":"/on-prem/v3/considerations"}]},{"item":"Binarly v2","pages":[{"title":"Binarly v2","href":"/on-prem/v2/considerations"}]}],"pages":[{"title":"On-Prem","href":"/on-prem/v3/considerations"}]}]},"basePath":"","title":"M2M Authentication - Binarly Transparency Platform","buildId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","deploymentId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","dynamics":[],"chunks":[]}