Prerequisites
- A Platform Application using Server Authentication (with Client Credentials Grant) authentication in the Box Developer Console
- 2FA enabled on your Box account for viewing and copying the application’s client secret from the configuration tab
- The application is authorized in the Box Admin Console
Your client secret is confidential and needs to be protected. Because this is
how we securely identify an application’s identity when obtaining an
Access Token, you do not want to freely distribute a client secret. This
includes via email, public forums and code repositories, distributed native
applications, or client-side code. If you would like to add more security
mechanisms, we recommend using our standard JWT application type.
How to use
When making your API call to obtain an Access Token, your request body needs to contain your client ID and client Secret. Set thegrant_type to client_credentials.
If you would like to authenticate as the application’s Service Account:
- set
box_subject_typetoenterprise - set
box_subject_idto the enterprise ID
- set
box_subject_typetouser - set
box_subject_idto the user ID - enable App + Enterprise Access and Generate User Access Tokens Box Developer Console
- set
box_subject_typetouser - set
box_subject_idto the user ID - enable Generate User Access Tokens in the Box Developer Console
Common Errors
Grant credentials are invalid
During authentication, you can encounter the following error:- the client ID and client secret passed are incorrect or are not for the same application,
-
the
box_subject_idcannot be used based on the selected application access.
-
to use a
box_subject_typeofuser, your application should be configured to generate user access tokens in the Advanced Features section of the Configuration tab.
- your application has not been authorized in the Box Admin Console
