You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69-1Lines changed: 69 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,74 @@ asyncio.run(main())
113
113
114
114
More info https://auth0.com/docs/secure/tokens/token-vault
115
115
116
+
### 5. Custom Token Exchange (Early Access)
117
+
118
+
> [!NOTE]
119
+
> This feature is currently available in [Early Access](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages#early-access) for Enterprise customers. Please reach out to Auth0 support to get it enabled for your tenant.
120
+
121
+
This feature requires a [confidential client](https://auth0.com/docs/get-started/applications/confidential-and-public-applications#confidential-applications) (both `client_id` and `client_secret` must be configured).
122
+
123
+
Custom Token Exchange allows you to exchange a subject token for Auth0 tokens using RFC 8693. This is useful for:
124
+
- Getting Auth0 tokens for another audience
125
+
- Integrating external identity providers
126
+
- Migrating to Auth0
127
+
128
+
```python
129
+
import asyncio
130
+
131
+
from auth0_api_python import ApiClient, ApiClientOptions
132
+
133
+
asyncdefmain():
134
+
api_client = ApiClient(ApiClientOptions(
135
+
domain="<AUTH0_DOMAIN>",
136
+
audience="<AUTH0_AUDIENCE>",
137
+
client_id="<AUTH0_CLIENT_ID>",
138
+
client_secret="<AUTH0_CLIENT_SECRET>",
139
+
))
140
+
141
+
subject_token ="..."# Token from your legacy system or external source
142
+
143
+
result =await api_client.get_token_by_exchange_profile(
144
+
subject_token=subject_token,
145
+
subject_token_type="urn:example:subject-token",
146
+
audience="https://api.example.com", # Optional - omit if your Action or tenant configuration sets the audience
# Result contains access_token, expires_in, expires_at, and optionally id_token, refresh_token
152
+
153
+
asyncio.run(main())
154
+
```
155
+
156
+
**Important:**
157
+
- Client authentication is sent via HTTP Basic (`client_id`/`client_secret`), not in the form body.
158
+
- The `subject_token_type` must match a Token Exchange Profile configured in Auth0. This URI identifies which profile will process the exchange and **must not** use IETF namespaces or vendor-controlled URNs; do not use Auth0/Okta namespaces. See the [Custom Token Exchange documentation](https://auth0.com/docs/authenticate/custom-token-exchange) for naming guidance.
159
+
- If neither an explicit `audience` nor tenant/Action logic sets it, you may receive a token not targeted at your API.
160
+
161
+
#### Additional Parameters
162
+
163
+
You can pass additional parameters for your Token Exchange Profile or Actions via the `extra` parameter. These are sent as form fields to Auth0 and may be inspected by Actions:
164
+
165
+
```python
166
+
result =await api_client.get_token_by_exchange_profile(
167
+
subject_token=subject_token,
168
+
subject_token_type="urn:example:subject-token",
169
+
audience="https://api.example.com",
170
+
extra={
171
+
"device_id": "device-12345",
172
+
"session_id": "sess-abc"
173
+
}
174
+
)
175
+
```
176
+
177
+
> [!WARNING]
178
+
> Extra parameters are sent as form fields and may appear in logs. Do not include secrets or sensitive data. Reserved OAuth parameter names (like `grant_type`, `client_id`, `scope`) cannot be used and will raise an error. Arrays are supported but limited to 20 values per key to prevent abuse.
If the token lacks `my_custom_claim` or fails any standard check (issuer mismatch, expired token, invalid signature), the method raises a `VerifyAccessTokenError`.
128
196
129
-
### 5. DPoP Authentication
197
+
### 6. DPoP Authentication
130
198
131
199
> [!NOTE]
132
200
> This feature is currently available in [Early Access](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages#early-access). Please reach out to Auth0 support to get it enabled for your tenant.
0 commit comments