Unable to create user and log in with auth0-node

I am getting Unauthorized errors when I try to create a user and then log in via NodeJS.

var auth = new auth0.AuthenticationClient({
    clientId: process.env.AUTH0_CLIENT_ID,
    domain: auth0Domain

const email = "..";
const password = "..";
const connection = ".."

const userCreateResult = await auth.database.signUp({email, password, connection})

// This fails
const authResult = await auth.oauth.passwordGrant({
    username: email,
    realm: connection

The error message us: Unauthorized

A few notes:

  • I’ve tried both the “Web App” and the “Machine-to-Machine App”… Both fail.
  • The Token Endpoint Authentication Method is POST
  • The Password Grant type is enabled

I noticed in the web view that the User record which results does not appear to have my application listed as authorized – could that be related? And how do I use the NodeJS management client to add that?

Hi @eob,

Welcome to the Community!

If you are seeing a user in the dashboard, it is unlikely you are getting that error when you try to create the user as you’ve stated.

Can you confirm which request is causing the error? It may also be helpful to post the error in its entirety.

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