Getting Error invalid_grant when trying to authenticate using JWT in node js

error: ‘invalid_grant’,
error_description: “Please check the ‘sub’ claim. The ‘sub’ specified is invalid.”

Hi @user237 , welcome to the forum!

There is not much information here to try to help you.

For which case I’ll point you to the most common cases:

  • Failure to submit and approve the JWT application on you console and admin console
  • Failure to create a correct JWT assertion or incorrect grant type.

For the first one, you need to go to your developer console at box, and submit your app for admin approval:

Looks something like this:

Then in the admin console:

For the second one and assuming you are trying to request a token, take a look at the API reference: Request access token

For a JWT token the grant_type must be urn:ietf:params:oauth:grant-type:jwt-bearer

and you must also send a proper JWT assertion in the format xxxxx.yyyy.zzzz. Creating this assertion is not always strait forward, and we can dive into it.

If you are using an SDK this is automatically handled for you.

Let us know if this helps.