Repository navigation
Commit 3a87ffa
committed
fix: persist resource metadata URL across OAuth redirects
In browser OAuth flows, when the user is redirected to the authorization
server and back, the resourceMetadataUrl discovered from the
WWW-Authenticate header was lost. This caused token exchange to fail
because the SDK couldn't locate the correct token endpoint.
This commit adds two optional methods to OAuthClientProvider:
- saveResourceMetadataUrl(url): Saves the URL before redirect
- resourceMetadataUrl(): Loads the saved URL after redirect
The SDK now:
1. Loads resourceMetadataUrl from provider if not passed in options
2. Saves resourceMetadataUrl before calling redirectToAuthorization()
This change is fully backwards-compatible as both methods are optional.
Providers that don't implement them will continue to work as before.
Fixes modelcontextprotocol#12341 parent 6b4d99f commit 3a87ffa
3 files changed
Lines changed: 423 additions & 2 deletions
File tree
- examples/client/src
- packages/client
- src/client
- test/client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
65 | 82 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
191 | 230 | | |
192 | 231 | | |
193 | 232 | | |
| |||
399 | 438 | | |
400 | 439 | | |
401 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
402 | 448 | | |
403 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
404 | 454 | | |
405 | 455 | | |
406 | 456 | | |
| |||
509 | 559 | | |
510 | 560 | | |
511 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
512 | 568 | | |
513 | 569 | | |
514 | 570 | | |
| |||
0 commit comments