Auth0 with AAD (Azure Active Directory)

Hi Team,
I am trying to implement authentication with auth0.
I init this though the cli, and updated the proper keys.

The app in auth0 is connected to AAD and working.

In RW:

  1. logIn() from “useAuth()” is working, bringing up auth0 widget.
  2. Widget go to Azure login
  3. This is redirecting and failing with 401 on the token request from - url is http://localhost:8910/callback?code=xxxx

relevant information:

import { AuthProvider } from ‘@redwoodjs/auth’
import { Auth0Client } from ‘@auth0/auth0-spa-js’
import ReactDOM from ‘react-dom’
import { RedwoodProvider, FatalErrorBoundary } from ‘@redwoodjs/web’
import FatalErrorPage from ‘src/pages/FatalErrorPage’

import Routes from 'src/Routes'

import './index.css'

const auth0 = new Auth0Client({
    domain: '',
    client_id: 'xxx',
    redirect_uri: 'http://localhost:8910/callback',
    cacheLocation: 'localstorage',
    audience: '',
  <FatalErrorBoundary page={FatalErrorPage}>
    <AuthProvider client={auth0} type="auth0">
        <Routes />

onClick={async () => {
if (isAuthenticated) {
await logOut()
} else {
await logIn()

{isAuthenticated ? ‘Log out’ : ‘Log in’}

newly created RW app, no additional package added

“private”: true,
“workspaces”: {
“packages”: [
“devDependencies”: {
@redwoodjs/core”: “^0.12.0”,
“netlify-plugin-prisma-provider”: “^0.3.0”
“eslintConfig”: {
“extends”: “@redwoodjs/eslint-config”
“engines”: {
“node”: “>=12”,
“yarn”: “>=1.15”

1 Like

I was responding re: the audience to say that in my setup doesn’t have /api/v2 but works – even though I looked at the machine-to-machine settings and the Unique identifier for the API there does. Odd.

That said, my login/logout is different from the doc’s example:

import { useAuth } from '@redwoodjs/auth'

const UserAuthTools = () => {
  const { loading, isAuthenticated, logIn, logOut } = useAuth()

  if (loading) {
    // auth is rehydrating
    return null

  return (
      onClick={async () => {
        if (isAuthenticated) {
          await logOut({ returnTo: process.env.AUTH0_REDIRECT_URI })
        } else {
          await logIn()
      {isAuthenticated ? 'Log out' : 'Log in'}

export default UserAuthTools
  • No navigate, because you setup your redirect to just be the root of your site
  • Thus no “/callback” either
  • I just allow http://localhost:8910, http://localhost:8910/* or the Netlify deployed urls
  • logout needs to know where to go on logout, so need to set returnTo
  • all your urls have to be allowed in Auth0 app setup (Allowed Callback URLs, Allowed Logout URLs, etc)
  • also be sure to set Application Login URI as <>/login

I just checked the request on one of my logins

Request URL: https://<appname>
Request URL: http://localhost:8910/?code=somecode&state=somestate

So, I might try removing the callback from your redirect_uri and see if that behaves better?