Implementing Auth0 using JWT Token only

Hello,
So I’m trying to build API which works around JWT instead of sessions.


const app = express()


app.use(auth({
    authRequired: false,
    auth0Logout: true,
    secret: '',
    baseURL: 'http://localhost:8080',
    clientID: ''',
    issuerBaseURL: '',

    routes: {
        callback: "/auth/callback",
        login: "/auth/login",
        logout: "/auth/logout",
        postLogoutRedirect:"http://localhost:8080/auth/logout/callback"
    }

  }));


app.use("/health", healthController)



app.use("/auth/logout/callback", (req: Request, res: Response) => {
    res.json({message: req.oidc.isAuthenticated()})
})

app.get("/", (req:  Request, res: Response) => {
    res.redirect("http://localhost:3000/dashboard")
})

app.listen(8080, () => {
    console.log("Application up and running")
})

But on making call to /oauth/token it shows 404. Not able figure out I’m doing things correctly or not.

Hi @lakshya,

Welcome to the Auth0 Community!

Have you made sure that the request looks something like the following:

curl --request POST \
  --url 'https://YOUR_DOMAIN/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=authorization_code \
  --data 'client_id=YOUR_CLIENT_ID' \
  --data 'client_secret={yourClientSecret}' \
  --data 'code=yourAuthorizationCode}' \
  --data 'redirect_uri=https://YOUR_APP/callback'

Usually, a 404 error indicates that the domain URL cannot be found. Please check that the domain looks like https://TENANT.REGION.auth0.com, for example, https://exampletenant.us.auth0.com.

Please let me know how this goes for you.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.