Skip to content

Commit 1248191

Browse files
Merge pull request #476 from kinde-oss/Claire/M2M-new-section-review
Claire/new section review - Updated procedures - Updated headings for better AI / indexing - Cross referenced existing topics
2 parents 16e7aa6 + dd4870c commit 1248191

15 files changed

+155
-195
lines changed

src/content/docs/build/tokens/token-customization.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ title: Token customization
44
sidebar:
55
order: 5
66
relatedArticles:
7+
- 7c283a32-96ec-4639-a902-ea1f4252d213
78
- d8069575-dfef-421d-8f3a-8f3efe9ad2f3
89
- 5a248c6f-c1ae-480a-95c3-d3c69c81598d
10+
- 3a16e08b-62c7-4725-8884-7065bfb2dbf2
911
app_context:
1012
- m: application_details
1113
s: tokens
@@ -45,7 +47,7 @@ You can:
4547

4648
### Add claims to M2M tokens
4749

48-
You can add feature flags to an M2M token.
50+
You can [add feature flags to an M2M token](/machine-to-machine-applications/m2m-application-setup/add-feature-flags-to-m2m-applications/).
4951

5052
## Add properties to tokens
5153

@@ -55,6 +57,25 @@ Properties are custom fields and information that you can attach to your users,
5557

5658
To make a property available in a token, you need to [make the property public](/properties/work-with-properties/manage-properties/), and then customize the token following the procedure above, to add a property.
5759

60+
The value will appear in the token under a `application_properties` claim:
61+
62+
```json
63+
{
64+
"application_properties": {
65+
"region": {
66+
"v": "eu"
67+
},
68+
"tier": {
69+
"v": "pro"
70+
}
71+
}
72+
}
73+
```
74+
75+
The `v` is a shortcode for the value of the property.
76+
77+
Only the properties you explicitly toggle on will be included.
78+
5879
## Token integration for third parties
5980

6081
Currently, we only support formatting for Hasura.

src/content/docs/machine-to-machine-applications/about-m2m/authenticate-with-m2m.mdx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ You can use a Machine-to-Machine (M2M) application in Kinde to request access to
1515

1616
Before an M2M app can request a token for a specific API audience, it must be authorized for that API.
1717

18-
You can do this in the Kinde dashboard:
19-
20-
1. Go to the M2M application
21-
2. Select **APIs**
22-
3. Choose which APIs this app is allowed to call
23-
4. Select **Save**
18+
If the app is not authorized for the given audience, the token request will fail.
2419

25-
You can also authorize apps programmatically using the Kinde Management API.
20+
1. Open the M2M application in Kinde.
21+
2. Select **APIs**.
22+
3. Select the three dots menu and authorize each API the app is allowed to call.
23+
4. Select **Save**.
2624

27-
If the app is not authorized for the given audience, the token request will fail.
25+
You can also [authorize apps programmatically](https://docs.kinde.com/kinde-apis/management/#tag/apis/patch/api/v1/apis/{api_id}/applications) using the Kinde Management API.
2826

2927
## Get an access token
3028

@@ -96,22 +94,22 @@ curl https://your-subdomain.kinde.com/api/v1/organizations \
9694
-H "Authorization: Bearer <token>"
9795
```
9896

99-
## Notes
97+
## Important information about tokens, audience, claims, and M2M apps
10098

10199
- Access tokens are valid for 1 hour by default.
102100
- The `audience` must match the intended API — tokens are only valid for the audience they’re issued for.
103101
- You can request multiple audiences
104102
- If your M2M app is scoped to an organization, the token will include the `org_code` trusted claim.
105103
- Tokens are JWTs and can be decoded to inspect claims using standard libraries or tools like [Kinde's JWT decoder](https://kinde.com/tools/online-jwt-decoder/).
106104

107-
## Test your M2M app from the Kinde dashboard
105+
## Test your M2M app in Kinde
108106

109-
You can also generate a token from the UI:
107+
You can also generate a token to help with testing.
110108

111-
1. Go to your M2M app in Kinde
112-
2. Select the **Test** tab
113-
3. Choose the API you want to test against
114-
4. Select **Generate token**
115-
5. Copy the access token and use it in your API requests
109+
1. Open your M2M app in Kinde.
110+
2. Select *APIs* in the menu, then open the API you want to test with the app.
111+
3. Select the **Test** tab
112+
4. Select **Get token**
113+
5. Copy the access token and use it in your API requests.
116114

117115
This is useful for debugging or verifying scopes and claims without writing code.

src/content/docs/machine-to-machine-applications/about-m2m/index.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ relatedArticles:
77
- 4cb63554-d6b3-45cf-bdad-2fac4790d3aa
88
- 961dea3c-d8e2-47a0-8ab7-deabdb2d6a01
99
- 65d72460-e870-4d6a-a1ea-35740ca0e2cc
10+
- 9f832d29-1b76-4bb2-b4dc-e4a9a9c327b3
1011
---
1112

1213
Machine-to-machine (M2M) applications allow you to authenticate backend services, scripts, or automation tools that need to call your APIs without a user being involved.
1314

1415
M2M apps in Kinde use the OAuth 2.0 client credentials flow to obtain access tokens. These tokens can then be used to securely interact with Kinde APIs or your own APIs.
1516

16-
You can create M2M applications for general use across your business, or scope them to a specific organization for tighter access control.
17+
You can create M2M applications for general use across your business, or [scope them to a specific organization](/machine-to-machine-applications/organization-scoped-m2m-apps/m2m-applications-for-organizations/) for tighter access control.
1718

1819
## Use cases
1920

@@ -36,11 +37,16 @@ These are tied to a single organization. Tokens issued to these apps include tru
3637

3738
## How M2M authentication works
3839

39-
1. Create an M2M app in the Kinde dashboard
40-
2. Use the provided `client_id` and `client_secret` in a client credentials request
41-
3. Receive an access token in response
42-
4. Use the token to call Kinde APIs or your own backend
40+
1. Create an M2M app in Kinde.
41+
2. Use the provided `client_id` and `client_secret` in a client credentials request.
42+
3. Receive an access token in response.
43+
4. Use the token to call Kinde APIs or your own backend.
4344

4445
Tokens can include scopes to limit access and, if scoped to an org, will include the `org_code` trusted claim.
4546

47+
## Best practices for M2M apps
4648

49+
- Use separate M2M apps for different scopes or services.
50+
- Limit the [scopes](https://docs.kinde.com/developer-tools/your-apis/custom-api-scopes/) assigned to each M2M app to the minimum required for its function.
51+
- [Rotate client secrets](/build/applications/rotate-client-secret/) periodically using the UI.
52+
- Avoid including any personally identifiable information (PII) in token claims.

src/content/docs/machine-to-machine-applications/about-m2m/m2m-quick-start-guide.mdx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,57 @@ relatedArticles:
1111

1212
This guide shows you how to create a Machine-to-Machine (M2M) application in Kinde, authorize it for an API, and use the client credentials flow to get a token and make a secure API request.
1313

14-
## Step 1 - Create a machine-to-machine app
14+
## Step 1: Create a machine-to-machine app
1515

16-
1. Go to the **Applications** section in your Kinde dashboard
17-
2. Select **Machine-to-machine apps**
18-
3. Choose **Add M2M application**
19-
4. Enter a name
16+
1. Go to the **Applications** section on the Kinde homepage and select **Add application**.
17+
2. In the window that opens, enter a name for the application.
18+
3. Select **Machine-to-machine (M2M)**.
19+
4. Select **Save**.
2020

21-
## Step 2 - Create an API in Kinde (if you don't have one)
21+
## Step 2: Create an API in Kinde (if you don't have one)
2222

2323
You can skip this step if you already have an API registered in Kinde.
2424

25-
1. Go to the **APIs** section in your Kinde dashboard
25+
1. Go to **Settings > Environment > APIs**.
2626
2. Select **Add API**
27-
3. Enter a name
28-
4. Select **Save**
27+
3. Enter a **Name** and **Audience**.
28+
4. Select **Save**.
2929

30-
For more detail, see [Register and manage APIs](/developer-tools/your-apis/register-manage-apis/).
30+
For more information, see [Register and manage APIs](/developer-tools/your-apis/register-manage-apis/).
3131

32-
## Step 3 - Authorize the app to access an API
32+
## Step 3: Authorize the app to access an API
3333

34-
1. Open your newly created app
35-
2. Go to the **APIs** tab
36-
3. Select the API (audience) this app should be allowed to call.
37-
4. Select **Save**.
34+
You need to authorize the API or else token requests will be rejected.
3835

39-
If you skip this step, token requests will be rejected.
36+
1. Open your newly created app.
37+
2. Select **APIs** in the side menu.
38+
3. Find the API to authorize, and select the three dots menu on the right.
39+
4. Select **Authorize**.
4040

41-
## Step 4 - (Optional) Add scopes
41+
## Step 4: Add scopes (optional)
4242

43-
If your API uses scopes to define permissions:
43+
Complete this step if your API uses scopes to define permissions.
4444

45-
1. Go to **APIs** in your Kinde dashboard
46-
2. Choose the API you’re protecting
47-
3. Add scopes (e.g. `read:users`, `write:flags`)
48-
4. Go back to your M2M app and assign those scopes
45+
1. Go to **Settings > Environment > APIs**.
46+
2. Choose the API you’re protecting.
47+
3. Select **Scopes** from the menu.
48+
4. Select **Add scope** and enter a scope name and description, then select **Save**.
49+
5. Repeat for each scope you want to add, e.g. `read:users`, `write:flags`.
50+
6. Go back to your M2M app and assign those scopes.
4951

50-
For more detail, see [Define and manage API scopes](/developer-tools/your-apis/api-scopes-m2m-applications/).
52+
For more information about how to assign scopes to an API, see [Define and manage API scopes](/developer-tools/your-apis/api-scopes-m2m-applications/).
5153

52-
## Step 5 - Get a token
54+
## Step 5: Get a token
5355

5456
You can test the app in one of two ways:
5557

5658
### Option A - Use the Test tab in Kinde
5759

58-
1. Open your M2M app
59-
2. Go to the **Test** tab
60-
3. Select the API (audience)
61-
4. Copy the generated token
60+
1. Open your M2M app.
61+
2. Select **APIs** in the menu and then open the API you want to test.
62+
3. Select **Test** in the menu.
63+
4. Select the Authorized application and then **Get token**.
64+
5. Copy the generated token.
6265

6366
### Option B - Use the client credentials flow directly
6467

@@ -82,7 +85,7 @@ The response will include a bearer token you can use in requests:
8285
}
8386
```
8487

85-
## Step 6 - Use the token in an API call
88+
## Step 6: Use the token in an API call
8689

8790
Include the token in the `Authorization` header:
8891

src/content/docs/machine-to-machine-applications/about-m2m/token-structure-and-claims-for-m2m-applications.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Access tokens issued by Kinde to Machine-to-Machine (M2M) applications are JSON
1313

1414
This reference explains what those claims are and how to use them securely in your APIs or services.
1515

16-
## How to view token claims
16+
## How to view M2M token claims
1717

1818
Tokens returned from the client credentials flow can be decoded using any standard JWT library, or online tools like [Kinde's JWT decoder](https://kinde.com/tools/online-jwt-decoder/).
1919

2020
You do **not** need to validate the signature unless you're verifying tokens on your own backend (outside of Kinde-hosted APIs). For most use cases, Kinde validates the token for you when you call our APIs.
2121

22-
## Example token payloads
22+
## Example M2M token payloads
2323

2424
### Global M2M app
2525

@@ -70,7 +70,7 @@ You do **not** need to validate the signature unless you're verifying tokens on
7070
}
7171
```
7272

73-
## Standard claims
73+
## Standard M2M token claims
7474

7575
| Claim | Description |
7676
|-------|-------------|
@@ -85,23 +85,22 @@ You do **not** need to validate the signature unless you're verifying tokens on
8585
| `scp` | The list of scopes initially requested |
8686
| `v` | The version of the token. |
8787

88-
## Additional claims for org-scoped apps
88+
## Additional M2M claims for org-scoped apps
8989

9090
| Claim | Description |
9191
|-------|-------------|
9292
| `org_code` | The organization code for the token. |
9393

9494

95-
96-
## Validating and using claims
95+
## Validating and using claims for M2M apps
9796

9897
In your API or backend service, you can use these claims to enforce access:
9998

10099
- Confirm the `aud` matches the expected audience for your API
101100
- If your endpoint is organization-specific (e.g. `/orgs/:org_code/...`), ensure that `org_code` from the token matches the route parameter
102101
- Use `scopes` to implement scope-based access control (e.g. `write:flags` required to enable a feature flag)
103102

104-
## Notes
103+
## Important information about M2M tokens, audiences, and scopes
105104

106105
- Tokens are signed using asymmetric keys (RS256)
107106
- You can retrieve your Kinde environment’s public keys from the [OpenID configuration endpoint](https://your-subdomain.kinde.com/.well-known/openid-configuration)

src/content/docs/machine-to-machine-applications/m2m-application-setup/add-feature-flags-to-m2m-applications.mdx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,31 @@ relatedArticles:
1111

1212
You can include feature flags in the tokens issued to machine-to-machine (M2M) applications in Kinde. This is helpful for enabling or disabling functionality in downstream systems based on feature access.
1313

14-
> **Note:** At this time, only **environment-level feature flags** can be included in M2M tokens. Support for organization-assigned flag values may be added in future releases.
14+
<Aside>
15+
16+
At this time, only **environment-level feature flags** can be included in M2M tokens. Support for organization-assigned flag values may be added in future releases.
17+
18+
</Aside>
1519

1620
## Define environment-level feature flags
1721

18-
Before including a flag in a token, you need to define it in your environment.
22+
Before including a flag in a token, you need to define it in your environment. This is the quick procedure (below), here's the [detailed procedure for adding feature flags](/releases/feature-flags/add-feature-flag/).
1923

20-
1. In Kinde, go to **Releases**
21-
2. Select **Add flag**
22-
3. Give the flag a key and (optionally) description
23-
4. Choose the flag type (boolean, string, number)
24-
5. Add a default value (optional)
25-
6. Select **Save**
24+
1. In Kinde, go to **Releases**.
25+
2. Select **Add feature flag**.
26+
3. Give the flag a key and (optionally) a description.
27+
4. Choose the flag type (boolean, string, integer, JSON).
28+
5. (Optional) Add a default value.
29+
6. (Optional) Decide if the feature flag value can be overridden.
30+
7. Select **Save**.
2631

2732
Once defined, this flag will be available for inclusion in any M2M token issued in the same environment.
2833

2934
## Include a flag in an M2M token
3035

31-
1. Go to **Applications > Your M2M app**
32-
2. Select the **Tokens** tab
33-
3. Under **Feature flags**, toggle on the flags you want included in the token
36+
1. Go to **Settings > Applications > Your M2M app**.
37+
2. Select **Tokens** in the menu.
38+
3. Under **Feature flags**, toggle on the flags you want included in the token.
3439

3540
These flags will be embedded in the token under the `feature_flags` claim:
3641

0 commit comments

Comments
 (0)