Commit 67694bc
authored
feat: add Auth0-Client telemetry header (#103)
* feat: add Auth0-Client telemetry header to all HTTP requests
Send an Auth0-Client header (base64-encoded JSON with SDK name,
version, and Python runtime) on every request to Auth0 endpoints.
This follows the standard Auth0 SDK telemetry convention.
- Add Telemetry class in telemetry.py for building and caching headers
- Add _get_http_client() helper to ServerClient, MyAccountClient, and
MfaClient to inject telemetry headers into all httpx requests
- Pass telemetry headers to AsyncOAuth2Client for token exchange calls
- Add unit tests for telemetry header format and integration
* fix: use Optional for Python 3.9 compatibility
Replace `from __future__ import annotations` with `Optional[dict[str, str]]`
syntax for the headers parameter in telemetry.py, mfa_client.py, and
my_account_client.py. This avoids triggering lint warnings on existing
Optional[X] annotations while maintaining Python 3.9 compatibility.
* fix: address review feedback for telemetry PR
* fix: address PR review feedback for telemetry
- Build headers eagerly in Telemetry.__init__ instead of lazy caching
- Narrow exception catch to PackageNotFoundError in Telemetry.default()
- Reverse header merge order so telemetry headers cannot be overwritten
- Fix resource leak in test by closing httpx.AsyncClient
- Replace mock-based OIDC test with direct header assertion
- Add test for AsyncOAuth2Client telemetry header propagation
- Add tests for MFA client header propagation and merge behavior1 parent 344ff66 commit 67694bc
5 files changed
Lines changed: 219 additions & 21 deletions
File tree
- src/auth0_server_python
- auth_server
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
157 | 164 | | |
158 | 165 | | |
159 | 166 | | |
160 | | - | |
| 167 | + | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| |||
232 | 239 | | |
233 | 240 | | |
234 | 241 | | |
235 | | - | |
| 242 | + | |
236 | 243 | | |
237 | 244 | | |
238 | 245 | | |
| |||
311 | 318 | | |
312 | 319 | | |
313 | 320 | | |
314 | | - | |
| 321 | + | |
315 | 322 | | |
316 | 323 | | |
317 | 324 | | |
| |||
395 | 402 | | |
396 | 403 | | |
397 | 404 | | |
398 | | - | |
| 405 | + | |
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
67 | | - | |
| 74 | + | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
| |||
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
| |||
176 | 183 | | |
177 | 184 | | |
178 | 185 | | |
179 | | - | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
243 | 250 | | |
244 | 251 | | |
245 | 252 | | |
246 | | - | |
| 253 | + | |
247 | 254 | | |
248 | 255 | | |
249 | 256 | | |
| |||
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
301 | | - | |
| 308 | + | |
302 | 309 | | |
303 | 310 | | |
304 | 311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| 164 | + | |
159 | 165 | | |
160 | 166 | | |
161 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
162 | 170 | | |
163 | 171 | | |
164 | 172 | | |
| |||
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
175 | | - | |
| 183 | + | |
| 184 | + | |
176 | 185 | | |
177 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
178 | 192 | | |
179 | 193 | | |
180 | 194 | | |
| |||
281 | 295 | | |
282 | 296 | | |
283 | 297 | | |
284 | | - | |
| 298 | + | |
285 | 299 | | |
286 | 300 | | |
287 | 301 | | |
| |||
352 | 366 | | |
353 | 367 | | |
354 | 368 | | |
355 | | - | |
| 369 | + | |
356 | 370 | | |
357 | 371 | | |
358 | 372 | | |
| |||
516 | 530 | | |
517 | 531 | | |
518 | 532 | | |
519 | | - | |
| 533 | + | |
520 | 534 | | |
521 | 535 | | |
522 | 536 | | |
| |||
1077 | 1091 | | |
1078 | 1092 | | |
1079 | 1093 | | |
1080 | | - | |
| 1094 | + | |
1081 | 1095 | | |
1082 | 1096 | | |
1083 | 1097 | | |
| |||
1391 | 1405 | | |
1392 | 1406 | | |
1393 | 1407 | | |
1394 | | - | |
| 1408 | + | |
1395 | 1409 | | |
1396 | 1410 | | |
1397 | 1411 | | |
| |||
1466 | 1480 | | |
1467 | 1481 | | |
1468 | 1482 | | |
1469 | | - | |
| 1483 | + | |
1470 | 1484 | | |
1471 | 1485 | | |
1472 | 1486 | | |
| |||
1918 | 1932 | | |
1919 | 1933 | | |
1920 | 1934 | | |
1921 | | - | |
| 1935 | + | |
1922 | 1936 | | |
1923 | 1937 | | |
1924 | 1938 | | |
| |||
2272 | 2286 | | |
2273 | 2287 | | |
2274 | 2288 | | |
2275 | | - | |
| 2289 | + | |
2276 | 2290 | | |
2277 | 2291 | | |
2278 | 2292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
0 commit comments