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:
- logIn() from “useAuth()” is working, bringing up auth0 widget.
- Widget go to Azure login
- This is redirecting and failing with 401 on the token request from
auth0.com/oauth/token
- url ishttp://localhost:8910/callback?code=xxxx
relevant information:
index.js:
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: 'xxx.auth0.com',
client_id: 'xxx',
redirect_uri: 'http://localhost:8910/callback',
cacheLocation: 'localstorage',
audience: 'https://xxx.auth0.com/api/v2/',
})
ReactDOM.render(
<FatalErrorBoundary page={FatalErrorPage}>
<AuthProvider client={auth0} type="auth0">
<RedwoodProvider>
<Routes />
</RedwoodProvider>
</AuthProvider>
</FatalErrorBoundary>,
document.getElementById('redwood-app')
)
Layout:
onClick={async () => {
if (isAuthenticated) {
await logOut()
navigate(‘/’)
} else {
await logIn()
}
}}
{isAuthenticated ? ‘Log out’ : ‘Log in’}
newly created RW app, no additional package added
package.json
{
“private”: true,
“workspaces”: {
“packages”: [
“api”,
“web”
]
},
“devDependencies”: {
“@redwoodjs/core”: “^0.12.0”,
“netlify-plugin-prisma-provider”: “^0.3.0”
},
“eslintConfig”: {
“extends”: “@redwoodjs/eslint-config”
},
“engines”: {
“node”: “>=12”,
“yarn”: “>=1.15”
}
}