I use msal-browser package for authentication and trying to set code_challenge
to something which I want than the auto generated one by msal-browser.
import * as msal from "@azure/msal-browser";
import pkceChallenge from "pkce-challenge"
const msalConfig = {
auth: {
clientId: "GUID", // This is the ONLY mandatory field; everything else is optional.
authority: "https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/B2C_signin_flow", // Choose sign-up/sign-in user-flow as your default.
knownAuthorities: [{authority}], // You must identify your tenant's domain as a known authority.
redirectUri: "http://localhost:6420", // You must register this URI on Azure Portal/App Registration. Defaults to "window.location.href".
}
};
const b2cScopes = ["https://{tenant}.onmicrosoft.com/010eb29e-d42b-4ca3-9c16-1961a528ce67/tasks.read",
"https://{tenant}.onmicrosoft.com/010eb29e-d42b-4ca3-9c16-1961a528de77/tasks.write"];
const myMSALObj = new msal.PublicClientApplication(msalConfig);
const pkce = pkceChallenge();
const loginRequest = {
scopes: ["openid", ...b2cScopes],
codeChallenge: pkce.code_challenge
}
myMSALObj.loginRedirect(loginRequest)
Looks like the above doesnt seem to work as the input param for loginRedirect
doesnt expect codeChallenge
property to be present.
How do I set this ?
Not possible, these are the supported params https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal.html#authenticationparameters