Skip to content

Conversation

@imfing
Copy link
Contributor

@imfing imfing commented May 29, 2025

The DynamicAuthProvider was unconditionally appending the scope parameter to OAuth authorization URLs, even when the scope string was empty.

Per OAuth 2.0 specification (RFC 6749), the scope parameter is optional in authorization requests.

If the client omits the scope parameter when requesting authorization, the authorization server MUST either process the request using a pre-defined default value or fail the request indicating an invalid scope.

More specifically, when server receives an empty scope string, "".split(" ") -> [''] can be problematic, e.g. in MCP TypeScript SDK

https://github.com/modelcontextprotocol/typescript-sdk/blob/590d4841373fc4eb86ecc9079834353a98cb84a3/src/server/auth/handlers/authorize.ts#L125

This PR modified the authorization URL construction to only include the scope parameter when non-empty scopes are actually provided. This ensures better compatibility with OAuth providers and follows the specification's recommendation to omit optional parameters when not needed.

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I applied your change to the other 2 flows

@TylerLeonhardt
Copy link
Member

@imfing can you approve the CLA so we can merge this in?

@vs-code-engineering vs-code-engineering bot added this to the May 2025 milestone May 30, 2025
@TylerLeonhardt TylerLeonhardt enabled auto-merge (squash) May 30, 2025 22:58
@imfing
Copy link
Contributor Author

imfing commented May 30, 2025

@microsoft-github-policy-service agree

@imfing
Copy link
Contributor Author

imfing commented May 30, 2025

@imfing can you approve the CLA so we can merge this in?

@TylerLeonhardt done, thank you

@TylerLeonhardt TylerLeonhardt merged commit 1b56299 into microsoft:main May 31, 2025
7 checks passed
@imfing imfing deleted the fix-scope branch May 31, 2025 00:03
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jul 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants