Client Credentials Grant

Guides Authentication Client Credentials Grant
Edit this page

Client Credentials Grant

Follow the steps below if you would like to leverage server authentication and verify your application's identity using a client ID and client secret.

Prerequisites

  • A Custom 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.

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 the grant_type to client_credentials.

If you would like to authenticate as the application's Service Account:

  • set box_subject_type to enterprise
  • set box_subject_id to the enterprise ID

If you would like to authenticate as a Managed User:

  • set box_subject_type to user
  • set box_subject_id to the user ID
cURL
curl --location --request POST ‘https://api.box.com/oauth2/token’ \
--header ‘Content-Type: application/x-www-form-urlencoded’ \
--data-urlencode ‘client_id=<client_id>’ \
--data-urlencode ‘client_secret=<client_secret>’ \
--data-urlencode ‘grant_type=client_credentials’ \
--data-urlencode ‘box_subject_type=enterprise’ \
--data-urlencode ‘box_subject_id=<enterprise_id>’

Box SDKs do not currently support this authentication method.

Common Errors

Grant credentials are invalid

This error indicates either:

  • the client ID and client secret passed are incorrect or are not for the same application
  • the box_subject_id cannot be used based on the selected application access