Box-node-sdk throws unauthorized for getAppAuthClient method

I have box account as individual. I have integrated box node sdk in my api server. I was passing my ACCOUNTID to authenticate box with getAppAuthClient method. But It was throwing "“Please check the ‘sub’ claim. The ‘sub’ specified is invalid.” Please can anyone help me on this?

Hello !

It’s probably because the user ID is not correct. Sub Claim refers to the ID you’re passing. You should check this page.

Can you check if your Account ID is correct ? You can find your Account ID on your Account Settings page on Box.com

If you’re still having the issue, is it a JWT app you’re using ?

Thanks

Hello,

I was send correct Account ID on my Account Settings page on [Box.com](http://box.com/]

It was JWT app while create the app in developer console I was choose "OAuth 2.0 with Client Credentials Grant (Server Authentication)" option.

Please let me know is there any other configurations required for authenticate in box node sdk?

Hello,

First, you mentioned many Authentication types. When you create the app, you need to select the correct authentication type you need. Please note : once you selected one, you can’t modify it. You’ll have to create another app, if the authentication type is not appropriated.

You have to choose between :

  • JWT app (server authentication)

  • OAuth 2.0 (user authentication)

  • Client Credentials Grant (server authentication)

If you’re using Box Node SDK, you should check who is the current user.
Can you please take a look to GitHub - box/box-node-sdk: A Javascript interface for interacting with the Box API. You can find the node package at

If you use this code :

// Get the user opject for the current user
client.users.get(client.CURRENT_USER_ID)
	.then(currentUser => { /* ... */ })
	.catch(error => { /* handle any errors */ });

You should get the current User ID you are logged in with. It shouuld match the User ID you have on your Account Settings page.

Finallty, don’t forget to configure correctly the app. What kind of user is supposed to interact with the app ? Is it the Admin ? A Managed User ? A Service account ?

Depending on the user type, you’ll need to select the appropriate permissions in the configuration.

But the first step is to determine the Authenticatiion type you need, as mentioned above.

Hi @sanjay_sahu ,

Can you access your admin console via https://app.box.com/master?

Hi @CodeBoxSeb ,

Thanks for your quick support authentication issue has been resolved. But I got another issue regarding upload file to folder through box node js sdk. error state that “stream ended unexpectedly”.

Can you help me out on this issue?

Hi @sanjay_sahu

It could be due to a network issue.
Can you please implement a “Retry” in your API call ? It could solve this issue.

Hi @CodeBoxSeb

thanks Issue was resolved due to network connection. I am not seeing webhooks which are created in v2 version in developer console. I been using below box node js sdk code for fetch all webhooks.

client.webhooks.getAll();

response
{
entries: ,
limit: 100
}

could you please help me out on this issue?

Hi @sanjay_sahu

Did you enable the “Manage Webhooks” scope in your app ?
It’s required.
In case of you haven’t seen the documentation : https://developer.box.com/guides/webhooks/v2/list-v2/

Also, please note : this API call will only list the webhooks for the authenticated user, not for any other users in the enterprise.

A post was split to a new topic: How to list all webhooks