From a274857a16d9f765b35254ee390e5ca194aefed0 Mon Sep 17 00:00:00 2001 From: Travis Walker Date: Tue, 7 Nov 2023 22:22:41 -0800 Subject: [PATCH] Adding logging to make regional scenarios more clear (#6641) Was able to confirm the regional configuration api works. Logs make the used endpoint misleading. Fix for https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/6510 --------- Co-authored-by: trwalke --- ...e-msal-node-92a2e589-8556-4d4c-8d36-f7375d161618.json | 7 +++++++ lib/msal-node/src/client/ClientApplication.ts | 9 +++++---- lib/msal-node/src/client/ClientCredentialClient.ts | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 change/@azure-msal-node-92a2e589-8556-4d4c-8d36-f7375d161618.json diff --git a/change/@azure-msal-node-92a2e589-8556-4d4c-8d36-f7375d161618.json b/change/@azure-msal-node-92a2e589-8556-4d4c-8d36-f7375d161618.json new file mode 100644 index 0000000000..c1a69f3712 --- /dev/null +++ b/change/@azure-msal-node-92a2e589-8556-4d4c-8d36-f7375d161618.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "Adding logging to make regional scenarios more clear", + "packageName": "@azure/msal-node", + "email": "trwalke@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/lib/msal-node/src/client/ClientApplication.ts b/lib/msal-node/src/client/ClientApplication.ts index 82c24f8d88..ab3e32703f 100644 --- a/lib/msal-node/src/client/ClientApplication.ts +++ b/lib/msal-node/src/client/ClientApplication.ts @@ -412,10 +412,6 @@ export abstract class ClientApplication { : this.config.auth.azureCloudOptions; // using null assertion operator as we ensure that all config values have default values in buildConfiguration() - this.logger.verbose( - `building oauth client configuration with the authority: ${authority}`, - requestCorrelationId - ); const discoveredAuthority = await this.createAuthority( authority, azureRegionConfiguration, @@ -423,6 +419,11 @@ export abstract class ClientApplication { userAzureCloudOptions ); + this.logger.info( + `Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`, + requestCorrelationId + ); + serverTelemetryManager?.updateRegionDiscoveryMetadata( discoveredAuthority.regionDiscoveryMetadata ); diff --git a/lib/msal-node/src/client/ClientCredentialClient.ts b/lib/msal-node/src/client/ClientCredentialClient.ts index 757cdebca7..ad9dd91b75 100644 --- a/lib/msal-node/src/client/ClientCredentialClient.ts +++ b/lib/msal-node/src/client/ClientCredentialClient.ts @@ -229,6 +229,7 @@ export class ClientCredentialClient extends BaseClient { authority.tokenEndpoint, queryParametersString ); + const requestBody = this.createTokenRequestBody(request); const headers: Record = this.createTokenRequestHeaders(); @@ -244,6 +245,10 @@ export class ClientCredentialClient extends BaseClient { sshKid: request.sshKid, }; + this.logger.info( + "Sending token request to endpoint: " + authority.tokenEndpoint + ); + reqTimestamp = TimeUtils.nowSeconds(); const response = await this.executePostToTokenEndpoint( endpoint,