2

Our app uses Authorization Code Flow with PKCE which is implemented using the MSAL-React package https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-reactand which runs on the Azure B2C Active Directory.

We currently authenticate users by getting them to type in their username and password, which is exchanged for an access_token which is then sent with every request. In this way the back end knows what to send the front end.

We have a new requirement which boils down to us getting an access_token from another method. This is to facilitate some new functionality not originally known to us.

We currently set the token using this code as part of the flow

msalInstance
  .acquireTokenSilent(tokenRequest)
  .then(async (tokenResponse) => {
    setToken(tokenResponse.accessToken)
  })

However we now need to set this token manually (don't worry about how we get this token just presume we have one)

Is there any way for MSAL to manually set a token that we pass to it ?

So something like this would be great (I know this doesn't exist)

comst token = {} // our token object which would be correct 
msalInstance
 .manuallyGetToken(token)
 .then(async (tokenResponse) => {
   setToken(tokenResponse.accessToken)
 })

The 'black box' nature of MSAL is proving to be difficult because it is hiding the internals of OAuth from us which is great until you need to deviate slightly from the way it is supposed to work.

0 Answers0