Support upscoping on insufficient_scope 403 (#1115)

Co-authored-by: Paul Carleton <paulc@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
This commit is contained in:
Nayana Parameswarappa 2025-11-20 11:37:44 -08:00 • committed by GitHub
commit 3485a06f85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -95,6 +95,16 @@ describe('OAuth Authorization', () => {
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ scope: scope });
});
it('returns error when present', async () => {
const mockResponse = {
headers: {
get: vi.fn(name => (name === 'WWW-Authenticate' ? `Bearer error="insufficient_scope", scope="admin"` : null))
}
} as unknown as Response;
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ error: 'insufficient_scope', scope: 'admin' });
});
});
describe('discoverOAuthProtectedResourceMetadata', () => {