Backend automation
A server needs to call a protected backend API on a schedule.
Kinde · Const
An M2M application authenticates backend services, scripts, or automation tools without a user. It uses OAuth 2.0 client credentials to obtain access tokens for Kinde APIs or your own APIs.
An M2M application represents a backend service, script, or automation tool rather than a person. It uses OAuth 2.0 client credentials: the service sends its client ID and secret, receives an access token, and uses that token for authorized API calls.
POST /oauth2/token with grant_type=client_credentials, client_id, client_secret, and audience| Name | Type | Description |
|---|---|---|
client_id | string | The application's client identifier issued by Kinde. |
client_secret | string | The application's secret issued by Kinde. |
grant_type | string | OAuth grant requested by the client; use client_credentials. |
audience | string | The API the token is intended to access. |
An OAuth access token that can be sent as a bearer token to an authorized API.
const tokenResponse = await fetch(`https://${process.env.KINDE_DOMAIN}/oauth2/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: process.env.KINDE_CLIENT_ID!,
client_secret: process.env.KINDE_CLIENT_SECRET!,
audience: process.env.API_AUDIENCE!
})
});
if (!tokenResponse.ok) throw new Error("Token request failed");
const { access_token } = await tokenResponse.json();
const apiResponse = await fetch(`${process.env.API_URL}/records`, {
headers: { Authorization: `Bearer ${access_token}` }
});
console.log(await apiResponse.json());The service exchanges its M2M credentials for an access token, then presents that token when calling the protected API.
A server needs to call a protected backend API on a schedule.
A command-line tool needs non-interactive API access.
A device or daemon must authenticate without a user session.
A service needs scoped access to the Kinde Management API.
An M2M application authenticates a backend service, script, or automation tool without a user. It uses the OAuth 2.0 client credentials grant to exchange its client ID and client secret for an access token.
Follow-up: How would you limit its authority? Authorize the application for only the required API and grant the smallest necessary scopes.
First create the application, then authorize it for the APIs it may call. The service sends its credentials in a client-credentials token request and uses the returned bearer token to call the API.
Follow-up: What must be configured before token use? The target API must be authorized for the M2M app, and the request must identify the intended API audience.
M2M apps suit backend services, CLIs, daemons, IoT devices, and automation because they operate without user interaction. Each app can be dedicated to a service or other machine identity.
Follow-up: Why use one app per service or environment? Separate credentials reduce blast radius and make least-privilege authorization and auditing clearer.
OAuth 2.0 client credentials flowClient IDClient Secretaccess tokenAPI authorizationscopesKinde Management APIorganization