Azure Auth works for public routes, for private routes I get empty pages

I was working on getting Azure Authentication to work on my Redwood App.
I got it working yay! However after I authenticate, if go to a private route, I’m put on a blank page.

I’m not sure where the problem is. I don’t see any console errors in my terminal or browser. I tried it with multiple accounts.

This seems similar to Custom auth - problem with getcurrentUser and protected routes - #8 by peterp

In that issue it’s said that Redwood is expecting the <AuthProvider client={azureActiveDirectoryClient} type="azureActiveDirectory"> a different set of methods.

Does client still need a custom mapping to get this to work?

I’ll be trying this tomorrow. However any input would be appreciated.

I’ve seen this reported twice before, but both those reports were with using Netlify Auth, so I thought it was isolated to that. But maybe/apparently not.

What worked in both cases to fix it was to upgrade to latest version of RW. If you’re already on the latest version Jace, I’d suggest nuking all your node_modules folders, and your yarn.lock file, and install again.

1 Like

Hi, Jace.

When you inspect the access_token and decoded info Azure sets (is it in localStorage?) does it seem ok? You have the user info and everything you expect?

One line in the client I see – though I have not used Azure AD before is:

    getUserMetadata: async () => (await client.getAccount()) || null,

The userMetadata determines the auth state:

      const userMetadata = await this.rwClient.getUserMetadata()
      if (!userMetadata) {
        this.setState(notAuthenticatedState)
      } else {
        await this.getToken()

So, if client.getAccount()) is null, then there would be issues.

Maybe @jeliasson can help as he implemented the client and I believe is using it?

1 Like

I removed the following now.
./node_modules/
./yarn.lock
./web/node_modules/
./api/node_modules/

Reran yarn
Loaded site up, logged in via azure auth.
Loaded home page (public) no problem, tried to load my /users in a private route, but, i get a blank page.

Note, I was on v0.28.0 before.
I upgraded following the upgrade instructions to v.0.29.0
yarn --force
yarn rw dev

Now it works. I’m not sure what fix in between 0.28 and 0.29 did it, but thanks guys!

Glad you got it working!

I’m not sure what can have caused that, but I will upgrade a Redwood application from 0.28.0 to 0.29.0 in the week and I will revert back if I get the same issue and identify what caused it.

Let us know if you stumble upon this wierd behavior again :slight_smile:

1 Like