- Notifications
You must be signed in to change notification settings - Fork 2.7k
Add extraQueryParams for api calls #7974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for passing extra query parameters (dc and slice) to custom authentication API requests in the MSAL browser library. This enhancement enables clients to specify datacenter and slice information in API calls for improved routing and flexibility.
- Added
extraQueryParametersto configuration types with typed keys fordcandslice - Updated API client constructors to accept and propagate extra query parameters throughout the client stack
- Introduced URL utility function to safely add/overwrite query parameters in API requests
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| CustomAuthConfiguration.ts | Added QueryKey type and extraQueryParameters field to CustomAuthOptions |
| CustomAuthStandardController.ts | Updated to pass extraQueryParameters from config to CustomAuthApiClient |
| CustomAuthApiClient.ts | Modified constructor to accept and pass extraQueryParameters to child API clients |
| BaseApiClient.ts | Updated constructor to accept extraQueryParameters and use new URL utility to append them |
| UrlUtils.ts | Added addQueryParametersToUrl utility function for safe query parameter handling |
| UrlUtils.spec.ts | Added comprehensive tests for the new addQueryParametersToUrl function |
| CustomAuthApiClient.spec.ts | Added tests for constructor with various extraQueryParameters scenarios |
This pull request adds support for passing extra query parameters (
dcandslice) to custom authentication API requests in the MSAL browser library. This enhancement allows clients to specify datacenter and slice information in API calls, improving flexibility and routing capabilities. The changes include updates to configuration types, API client constructors, URL building utilities, and comprehensive tests to ensure correct behavior.Support for extra query parameters in custom authentication:
extraQueryParameters(with keysdcandslice) toCustomAuthOptionsand associated types, enabling clients to specify additional query parameters for custom authentication requests.BaseApiClientandCustomAuthApiClientto accept and propagateextraQueryParameters, ensuring these parameters are available throughout the API client stack. [1] [2]URL utilities and API request handling:
addQueryParametersToUrlutility function inUrlUtils.ts, which safely adds/overwrites query parameters in URLs, and integrated this function into API request construction to append the extra parameters to outgoing requests. [1] [2] [3]Testing and validation:
CustomAuthApiClientandaddQueryParametersToUrlto verify correct handling of extra query parameters, including cases for single, multiple, undefined, empty, and overwriting scenarios. [1] [2] [3]