Custom auth - problem with getcurrentUser and protected routes

I think the problem is here:

You’re passing the raw “authClient” to redwood without mapping the values. You’ll need to map the “shape” of Msal to match that which Redwood expects, what I mean by this is that Redwood expects your client object to have the following named functions that return the correct values:

You can see the implementation of various other clients over here: https://github.com/redwoodjs/redwood/tree/main/packages/auth/src/authClients

As an example; if new Msal returns an object that has a LogInWithPopUp method, you would have to map this method like this:

const originalAuthClient = new Msal.UserAgentApplication(msalConfig)

const myAuthClient = {
    type: 'custom',
    client: originalAuthClient,
    login: originalAuthClient.LogInWithPopUp,
   /* ...  implement getToken, logout, getUserMetadata */
}
1 Like