Skip to main content

Unable to create a Box API connection using client ID and client secret


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.

6 replies

smartoneinok Box
Forum|alt.badge.img
  • Senior Developer Advocate
  • 181 replies
  • October 16, 2023

Hello 👋,


May I have the client id of the application?


Thanks,

Alex, Box Developer Advocate 🥑


  • 1 reply
  • October 18, 2023

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?


smartoneinok Box
Forum|alt.badge.img
  • Senior Developer Advocate
  • 181 replies
  • October 18, 2023

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.


  • 1 reply
  • December 1, 2023

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?


smartoneinok Box
Forum|alt.badge.img

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


  • New Member
  • 1 reply
  • December 24, 2024

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: es0zd124z18wotpspprbzalnl2rcn1vu

can you pls help?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings