Skip to main content

I am fairly new to Box Java API. I am trying to use the BoxAPIConnection API to get a connection to Box using client id and secret.



Here is the code that I am using as per the documentation:



BoxAPIConnection api = new BoxAPIConnection(“<client_id>”,“<client_secret>”);



I am getting the following error:



Exception in thread “main” com.box.sdk.BoxAPIResponseException: The API returned an error code 401 | .08eaad29f26b48b94acb1d577e5ceb51f]


at box.java.sdk@4.5.0/com.box.sdk.BoxAPIResponse.toBoxResponse(BoxAPIResponse.java:147)


at box.java.sdk@4.5.0/com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:616)


at box.java.sdk@4.5.0/com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:380)


at box.java.sdk@4.5.0/com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:106)


at box.java.sdk@4.5.0/com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:17)


at box.java.sdk@4.5.0/com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:347)


at box.java.sdk@4.5.0/com.box.sdk.BoxJSONRequest.send(BoxJSONRequest.java:101)


at box.java.sdk@4.5.0/com.box.sdk.BoxUser.getCurrentUser(BoxUser.java:199)



The code works fine if I call the API using developer token.

Hello 👋,



May I have the client id of the application?



Thanks,


Alex, Box Developer Advocate 🥑


Hi Team,



I am also facing the same issue with Client ID & Client Secret. I am getting 400 error.


box_subject_type" for the “client_credentials” grant type can not be used. This is my personal account I have created for Testing purpose only. I have to do this testing from personal as my corporate account does not allow Testing on enterprise ID.


Here is my client ID: 9p0vtjne3m7ijzb3u2xwfcdotd0s9r7m


can you pls assist?


It looks like you are trying to use a Client Credentials authentication method - which is not possible with a free account. I changed your account a developer tarriff which should allow you to go through the process of approving the application.


Hi Team,



I am also facing the similar with Client ID & Client Secret. I am getting 400 error.


box_subject_type" for the “client_credentials” grant type can not be used.


This is my personal account I have created for Testing purpose only. I have to do this testing from personal as my enterprise account does not allow Testing on enterprise ID.


Here is my client ID: r1gavbz254ttpcfjrg5kk5c92koleyzy


can you pls help?


@user144 You should have access to approve application in your admin console now. let me know if you get stuck.


Reply