I am working with a development team that is leveraging Microsoft's MSAL.js library for a vanilla javascript application. The authConfig.js has the following necessary code:
const msalConfig = {
auth: {
clientId: "11111111-1111-1111-111111111111",
authority: "https://login.microsoftonline.com/11111111-1111-1111-1111111111111",
redirectUri: "http://localhost:3000/",
},
cache: {
cacheLocation: "sessionStorage", // This configures where your cache will be stored
storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
}
I need to be able to change the clientId and RedirectURI for Dev, QA and Prod. Is there a way to dependency inject these values for the DevOps pipeline?
Is there a way to dependency inject these values for the DevOps pipeline?
I would like to share the following two methods:
Method1:
You can add PowerShell task in each stage to replace the value of ClientId and redirectUri.
1.Set the variable to save the Old value and New Value.

2.Run the following Powershell script:
(Get-Content .\authConfig.js).replace('$(oldid)', '$(newid)') | Set-Content .\authConfig.js
(Get-Content .\authConfig.js).replace('$(oldredirectUri)', '$(newredirectUri)') | Set-Content .\authConfig.js
Method2 :
You could try to use the Replace Tokens task from the Replace Tokens Extension.
For more info, you can refer to this ticket: Replace token task ticket