Skip to content

Commit 9f522d4

Browse files
[V5] Updates samples to match the deprecation of proxyUrl and customAgentOptions in msal-node's HttpClient (#8139)
1 parent c11406d commit 9f522d4

File tree

11 files changed

+117
-589
lines changed

11 files changed

+117
-589
lines changed

package-lock.json

Lines changed: 57 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/msal-node-samples/auth-code-distributed-cache/src/AuthProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export class AuthProvider {
6363
logLevel: LogLevel.Verbose,
6464
piiLoggingEnabled: false,
6565
},
66-
// proxyUrl: "http://localhost:8888" // uncomment to capture traffic with Fiddler
6766
},
6867
} as Configuration;
6968

samples/msal-node-samples/client-credentials-distributed-cache/src/AuthProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export class AuthProvider {
6565
logLevel: LogLevel.Trace,
6666
piiLoggingEnabled: false,
6767
},
68-
// proxyUrl: "http://localhost:8888" // uncomment to capture traffic with Fiddler
6968
},
7069
} as Configuration;
7170

samples/msal-node-samples/custom-INetworkModule-and-network-tracing/HttpClientAxios.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,28 @@ import {
88
NetworkRequestOptions,
99
NetworkResponse,
1010
} from "@azure/msal-node";
11-
import axios, { AxiosRequestConfig } from "axios";
11+
import axios, {
12+
// AxiosProxyConfig,
13+
AxiosRequestConfig,
14+
AxiosResponse,
15+
} from "axios";
1216

1317
enum HttpMethod {
14-
GET = "get",
15-
POST = "post",
18+
GET = "GET",
19+
POST = "POST",
1620
}
1721

22+
/*const proxy: AxiosProxyConfig = {
23+
protocol: "http", // Can also be "https"
24+
host: "localhost",
25+
port: 8866, // Fiddler Everywhere default port; configurable inside of Fiddler's settings
26+
// port: 8888, // Fiddler Classic default port; configurable inside of Fiddler's settings
27+
// auth: { // Optional: for authenticated proxies
28+
// username: "username",
29+
// password: "password",
30+
// }
31+
};*/
32+
1833
/**
1934
* This class implements the API for network requests.
2035
*/
@@ -26,18 +41,19 @@ export class HttpClientAxios implements INetworkModule {
2641
*/
2742
async sendGetRequestAsync<T>(
2843
url: string,
29-
options?: NetworkRequestOptions
44+
options?: NetworkRequestOptions,
45+
timeout?: number
3046
): Promise<NetworkResponse<T>> {
3147
const request: AxiosRequestConfig = {
3248
method: HttpMethod.GET,
3349
url: url,
34-
/* istanbul ignore next */
50+
timeout: timeout,
3551
headers: options && options.headers,
36-
/* istanbul ignore next */
3752
validateStatus: () => true,
53+
// proxy: proxy,
3854
};
3955

40-
const response = await axios(request);
56+
const response: AxiosResponse = await axios(request);
4157
return {
4258
headers: response.headers as Record<string, string>,
4359
body: response.data as T,
@@ -52,22 +68,18 @@ export class HttpClientAxios implements INetworkModule {
5268
*/
5369
async sendPostRequestAsync<T>(
5470
url: string,
55-
options?: NetworkRequestOptions,
56-
cancellationToken?: number
71+
options?: NetworkRequestOptions
5772
): Promise<NetworkResponse<T>> {
5873
const request: AxiosRequestConfig = {
5974
method: HttpMethod.POST,
6075
url: url,
61-
/* istanbul ignore next */
6276
data: (options && options.body) || "",
63-
timeout: cancellationToken,
64-
/* istanbul ignore next */
6577
headers: options && options.headers,
66-
/* istanbul ignore next */
6778
validateStatus: () => true,
79+
// proxy: proxy,
6880
};
6981

70-
const response = await axios(request);
82+
const response: AxiosResponse = await axios(request);
7183
return {
7284
headers: response.headers as Record<string, string>,
7385
body: response.data as T,

0 commit comments

Comments
 (0)