Repository navigation
fix(auth): use OAuth2 v2 authorize URL for browser login - #7718
Open
mujakayadan wants to merge 2 commits into
Open
mujakayadan wants to merge 2 commits into
mujakayadan wants to merge 2 commits into
Conversation
AuthServer built a v1 authorize URL with resource=, then MSAL redeemed the code at the v2 token endpoint. That mix fails personal Microsoft accounts with AADSTS500202. Use /oauth2/v2.0/authorize with scopes instead. Fixes pnp#7717
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Human validation against Entra/MSA is still needed because the failure occurs during live authorization-code redemption, which the separately mocked browser-authorization and token-exchange tests do not cover.
No open issues 🎉
What changed in this PR
Aligns CLI browser authentication with MSAL’s OAuth2 v2 token exchange to address personal Microsoft account sign-in failures reported in #7717.
Changes:
- Replaces the v1 authorization URL and
resourceparameter with the v2 endpoint and scopes. - Encodes the scopes and redirect URI.
- Adds a regression test checking the v2 endpoint, resource scope, and absence of
resource.
Build, tests, and lint were not run during this review. Manual personal-account sign-in validation remains pending.
| File | Description |
|---|---|
src/AuthServer.ts |
Constructs the v2 authorization URL with encoded scopes and redirect URI. |
src/AuthServer.spec.ts |
Adds regression coverage for the updated authorization URL. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AuthServerbrowser login from the legacy v1/oauth2/authorize?…&resource=URL to/oauth2/v2.0/authorizewithscopeso the auth code matches MSALacquireTokenByCode(v2 token endpoint).AADSTS500202after the localhost success page.scope(notresource).Fixes #7717
Test plan
npm run build&&npx mocha --grep AuthServer(7 passing)m365 login --authType browser --appId <msa-enabled-app> --tenant commonwith a personal Outlook.com account completes withoutAADSTS500202