Repository navigation
fix(oauth): surface safe token exchange failures - #2698
Merged
benjaminshafii merged 2 commits intoJul 13, 2026
Merged
benjaminshafii merged 2 commits into
benjaminshafii merged 2 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Jul 13, 2026
benjaminshafii
marked this pull request as ready for review
July 13, 2026 02:49
benjaminshafii
pushed a commit
that referenced
this pull request
Jul 13, 2026
* feat(den): add Microsoft 365 permission parity * feat(mcp): add package-first enterprise mock lab (#2670) * feat(mcp): add enterprise mock foundation artifacts * chore(mcp): wire enterprise mock workspaces * ci(mcp): enforce enterprise mock checks * fix(mcp): emit a truly invalid schema fault * feat(mcp): configure exact mock OAuth redirects * feat(mcp): strengthen mock OAuth verification * fix(mcp): accept Azure localhost OAuth callbacks * fix(mcp): close mock sockets across scenario restarts * fix(mcp): make mock listener restarts explicit * fix(oauth): surface safe token exchange failures (#2698) * fix(oauth): surface safe token exchange failures * test(oauth): use synthetic provider diagnostics * feat(mcp): add package-first enterprise MCP client (#2694) * feat(mcp): add enterprise MCP client package * refactor(mcp): harden enterprise client contracts * fix(mcp): preserve the first failing request phase --------- Co-authored-by: Benjamin Shafii <[email protected]> * feat(den): add Microsoft 365 permission parity * fix(oauth): use localhost for local Den callbacks --------- Co-authored-by: Benjamin Shafii <[email protected]>
This branch was successfully 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.
Important
This is a focused native-provider OAuth fix. It covers Den's Microsoft 365/Google-style OAuth callback and token exchange. It does not implement or claim conformance with Microsoft Work IQ, Microsoft Enterprise MCP, Agent 365, or ServiceNow MCP.
Relationship to the package-first MCP work
The Microsoft 365 quick add is a native OAuth/Microsoft Graph integration. This PR improves and verifies that native path; it does not use
@openwork/enterprise-mcp-client, even whenDEN_ENABLE_ENTERPRISE_MCP_CLIENT=trueis enabled. That flag selects Den's external remote MCP runtime only.The longer-term direction is to place reusable remote MCP behavior behind package contracts. Migrating this native Microsoft 365 provider is outside the current MCP package scope and must not be inferred from the successful connection below.
Managerial summary
We set out to make an administrator's failed Connect attempt identify the actual source of failure.
During a real Microsoft 365 development connection, Microsoft sign-in and consent succeeded and the browser returned to Den. Den then displayed only:
That message proved the HTTP status but hid the actionable provider diagnosis. A controlled replay of the same token request showed:
invalid_client;AADSTS7000215;The tenant ID, client ID, application state, web redirect type, exact
localhostcallback, authorization code return, and PKCE request were all correct. Replacing the stored secret value and starting a fresh authorization completed the connection.Before and after
Token request failed with status <n>.AUTH_TOKEN_ACQUISITION, stable code, status, and safe provider trace/correlation fields.invalid_client,invalid_grant, invalid scope, denied consent, and provider availability looked alike.For the verified Microsoft failure, the callback now says:
The page also displays the Den diagnostic reference.
Root-cause record
AUTH_TOKEN_ACQUISITION/ client authenticationinvalid_client,AADSTS7000215, trace/correlation/timestampSafe diagnostic contract
Retained when valid and bounded:
Never retained or returned:
Microsoft
AADSTS7000215receives provider-specific wording because it was verified against the development tenant and is a stable Entra error class. A ServiceNow-styleinvalid_clientremains provider-generic unless an approved ServiceNow test instance supplies authoritative wire evidence.Validation
Passed on Node 24 / pnpm 11.4 / Bun:
Result: 10 tests passed / 41 expectations.
Coverage includes:
localhostcallback;AADSTS7000215classification and correlation evidence;invalid_clientclassification without invented provider wording;Reviewer boundaries
Verified:
Not verified by this PR:
Those belong to the enterprise mock/client and approved-tenant verification tracks, not this focused fix.