Skip to content

Commit 70ddef2

Browse files
committed
Fix OAuth redirect URI mismatch in debug flow
Register both normal and debug redirect URIs in client metadata to prevent mismatch errors when using the Auth tab's debug mode versus normal connection flow.
1 parent 2352993 commit 70ddef2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

client/src/lib/auth.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
117117
return window.location.origin + "/oauth/callback";
118118
}
119119

120+
get debugRedirectUrl() {
121+
return window.location.origin + "/oauth/callback/debug";
122+
}
123+
120124
get clientMetadata(): OAuthClientMetadata {
125+
// Register both redirect URIs to support both normal and debug flows
121126
return {
122-
redirect_uris: [this.redirectUrl],
127+
redirect_uris: [this.redirectUrl, this.debugRedirectUrl],
123128
token_endpoint_auth_method: "none",
124129
grant_types: ["authorization_code", "refresh_token"],
125130
response_types: ["code"],
@@ -223,11 +228,13 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
223228
}
224229
}
225230

226-
// Overrides debug URL and allows saving server OAuth metadata to
231+
// Overrides redirect URL to use the debug endpoint and allows saving server OAuth metadata to
227232
// display in debug UI.
228233
export class DebugInspectorOAuthClientProvider extends InspectorOAuthClientProvider {
229234
get redirectUrl(): string {
230-
return `${window.location.origin}/oauth/callback/debug`;
235+
// We can use the debug redirect URL here because it was already registered
236+
// in the parent class's clientMetadata along with the normal redirect URL
237+
return this.debugRedirectUrl;
231238
}
232239

233240
saveServerMetadata(metadata: OAuthMetadata) {

0 commit comments

Comments
 (0)