Merged
Conversation
added 3 commits
July 16, 2025 19:42
…ve OAuth flow integration
…nd update test setup for MsalTokenProvider integration
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances token management by introducing automatic refresh and caching in OAuthFlow, streamlines UserTokenClient with Axios interceptors and error handling, and replaces the legacy BaseAdapter with a more flexible CloudAdapter across samples, tests, and application setup.
- Add
refreshTokeninOAuthFlowusing JWT for caching and auto-refresh. - Refactor
UserTokenClientto remove redundant try-catches, add response interceptors, andupdateAuthToken. - Update adapter logic to use
CloudAdapterwith optionalAuthConfiguration,AuthProvider, andUserTokenClient.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/compat/oauthFlowHandler.ts | Updated sample to load auth config and instantiate OAuthFlow with new UserTokenClient. |
| samples/auth/autoAuth.ts | Removed trailing whitespace. |
| packages/agents-hosting/test/hosting/oauthflow.test.ts | Updated tests to mock MsalTokenProvider, integrate refreshToken calls, and adjust context stubbing. |
| packages/agents-hosting/src/oauth/userTokenClient.ts | Refactored constructor signature, removed redundant error handling, added Axios response interceptors, and updateAuthToken. |
| packages/agents-hosting/src/oauth/oAuthFlow.ts | Replaced initializeTokenClient with refreshToken, introduced JWT caching and constructor signature update. |
| packages/agents-hosting/src/oauth/index.ts | Removed duplicate export of userTokenClient. |
| packages/agents-hosting/src/cloudAdapter.ts | Modified constructor to load default config and accept optional UserTokenClient; ensure adapter fallback. |
| packages/agents-hosting/src/baseAdapter.ts | Added userTokenClient property on BaseAdapter. |
| packages/agents-hosting/src/app/authorization.ts | Updated Authorization to accept and pass through UserTokenClient to OAuthFlow. |
| packages/agents-hosting/src/app/agentApplication.ts | Swapped BaseAdapter for CloudAdapter, added fallback instantiation, and wired token client into auth. |
| packages/agents-hosting-express/src/startServer.ts | Changed CloudAdapter initialization to no-arg constructor for default environment config. |
| __state/state.json | Added an initial empty state file. |
Comments suppressed due to low confidence (1)
packages/agents-hosting/src/cloudAdapter.ts:51
MsalTokenProvideris referenced but not imported. Addimport { MsalTokenProvider } from './auth/authProvider'(or the correct path) to avoid runtime errors.
this.authProvider = authProvider ?? new MsalTokenProvider()
added 3 commits
July 16, 2025 23:35
rido-min
commented
Jul 16, 2025
rido-min
commented
Jul 16, 2025
axelsrz
approved these changes
Jul 17, 2025
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.
fixes #459 and #263
This pull request introduces significant changes to the
agents-hostingpackage, focusing on enhancing token management, improving theCloudAdapterandOAuthFlowclasses, and simplifying error handling within theUserTokenClient. The most important updates involve replacing theBaseAdapterwithCloudAdapter, improving token refresh logic, and streamlining error handling in theUserTokenClient.Token Management Enhancements:
packages/agents-hosting/src/oauth/oAuthFlow.ts: Replaced theinitializeTokenClientmethod withrefreshToken, adding token caching and automatic refresh logic usingjwt. This ensures that tokens are kept up-to-date and reduces redundant initialization. [1] [2]Adapter Improvements:
packages/agents-hosting/src/app/agentApplication.ts: Replaced theBaseAdapterwithCloudAdapterand added fallback logic to initialize a newCloudAdapterwhen no adapter is provided. [1] [2]packages/agents-hosting/src/cloudAdapter.ts: Updated theCloudAdapterconstructor to support optional parameters forAuthConfiguration,AuthProvider, andUserTokenClient, enabling more flexible initialization.Error Handling Simplification:
packages/agents-hosting/src/oauth/userTokenClient.ts: Removed redundant try-catch blocks in methods likegetUserToken,signOut, andgetSignInResource. Added response interceptors for improved logging and error handling. [1] [2] [3]Authorization Enhancements:
packages/agents-hosting/src/app/authorization.ts: Updated theAuthorizationclass to useUserTokenClientfor token management, ensuring tighter integration with the new token handling logic. [1] [2]Miscellaneous Updates:
packages/agents-hosting/src/oauth/index.ts: Fixed duplicate export ofuserTokenClient.