From f3584f2a4162febadf39300d7f37be63a91ce05d Mon Sep 17 00:00:00 2001 From: Jonathan Wang <229140959@qq.com> Date: Tue, 15 Jul 2025 00:24:10 +0800 Subject: [PATCH] fix: use authorization_server_url as issuer when fetching metadata (#763) --- src/client/auth.test.ts | 6 +++--- src/client/auth.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/auth.test.ts b/src/client/auth.test.ts index c5021def..ce0cc708 100644 --- a/src/client/auth.test.ts +++ b/src/client/auth.test.ts @@ -1778,7 +1778,7 @@ describe("OAuth Authorization", () => { status: 200, json: async () => ({ resource: "https://my.resource.com/", - authorization_servers: ["https://auth.example.com/"], + authorization_servers: ["https://auth.example.com/oauth"], }), }); } else if (urlString === "https://auth.example.com/.well-known/oauth-authorization-server/path/name") { @@ -1821,8 +1821,8 @@ describe("OAuth Authorization", () => { // First call should be to PRM expect(calls[0][0].toString()).toBe("https://my.resource.com/.well-known/oauth-protected-resource/path/name"); - // Second call should be to AS metadata with the path from serverUrl - expect(calls[1][0].toString()).toBe("https://auth.example.com/.well-known/oauth-authorization-server/path/name"); + // Second call should be to AS metadata with the path from authorization server + expect(calls[1][0].toString()).toBe("https://auth.example.com/.well-known/oauth-authorization-server/oauth"); }); }); diff --git a/src/client/auth.ts b/src/client/auth.ts index 47400768..4a8bbe2d 100644 --- a/src/client/auth.ts +++ b/src/client/auth.ts @@ -606,7 +606,7 @@ export async function discoverOAuthMetadata( protocolVersion ??= LATEST_PROTOCOL_VERSION; const response = await discoverMetadataWithFallback( - issuer, + authorizationServerUrl, 'oauth-authorization-server', { protocolVersion,