Skip to main content
Question

Not Authenticate

  • May 22, 2025
  • 5 replies
  • 13 views

Forum|alt.badge.img

Good afternoon, I have the following problem.
When trying to obtain user information, it gives me the following message:

"Grant credentials are invalid"

I have an application with client credentials (server authentication)

I am using the Java SDK and the line of code I use to get the permission is:

BoxCCGAPIConnection api = BoxCCGAPIConnection.userConnection(CLIENT_ID, SECRET_CLIENT, USER_ID);

 

My CLIENT_ID is 0046s531alxnmszzy4wx2jdtn91s12a0

5 replies

Forum|alt.badge.img

Hello, 

It looks like you set up your app to be App + Enterprise set up... is this correct? BOX1_RZ44XWRIYqJC8cwG1Q8j3A.png

I believe you need to pass in the enterprise id... not a user id.. can you try and report back? 

Thanks, 

Alex, Box Developer Advocate


Forum|alt.badge.img

Yes, it is like that, but indicating the company ID, we cannot access either

BOX1_5CrgBbR7iDRYv2wYRymcEA.png

This is the error

 

BOX1_yjfwVI8N4fUD2-ANhTIAcw.png

 

thank you very much for your help


Forum|alt.badge.img

I think I see the issue... there are two cca java methods... and you are still using the user one... below is the enterprise one to try

BoxCCGAPIConnection api = BoxCCGAPIConnection.applicationServiceAccountConnection(
    "client_id",
    "client_secret",
    "enterprise_id"
);


Forum|alt.badge.img

Alex, thank you very much for your answer.

I had to wait a few days for the app to be authorized in Box to try again. Finally today they have authorized it, the authentication occurs without error, however my new problem is that I cannot read the folders that I have in Box.

This is an extract of my code:

 

BOX1_dn0uXboFJEtLLP2UZ8teoA.png

 

This line occurs without error:

BoxCCGAPIConnection api = BoxCCGAPIConnection.applicationServiceAccountConnection(ID_CLIENTE, SECRET_CLIENT, ENTERPRISE_ID);

However when I try to loop through the folders, this line gives me the result that I don't have any BoxItem.Info

for (BoxItem.Info itemInfo : folder) {

 


Forum|alt.badge.img

So, when you use CCA as the authentication type, a service account is automatically created... and that account has its own content - which since its new probably has no content. In order to see your users content, you would want to make an as-user call, which allows the app to impersonate your user account.