Unauthorised error from getProfile when using node-auth0

Viewed 15

I am trying to migrate authentication via auth0 from a jvm based solution which uses auth0 rest api to a node based solution using node-auth0. At present its a 2 step process:

  1. Get token via POST /oauth/token
  2. Get user profile via /userInfo

In the node application, I am constructing AuthenticationClient while providing clientId, clientSecret and domain as AuthenticationClientOptions and able to get the token successfully using passwordGrant but when I use the same authenticationClient object to call getProfile while providing the token obtained from passwordGrant, I get this error:

Request failed with status code 401

What’s confusing is that in Auth0 dashboard, this request is successful.

I am using node-auth0 SDK Version: 2.42.0 on Node 15.14.0

1 Answers

The token obtained via passwordGrant will be processed to respond for userInfo. Hence, the token must have in its audience claim <your-auth0-domain>/userInfo.

Related