By default, the Access Token acquired with JWT is tied to the Service
Account for the application. Any API call made with this token will come
from the application. This account does not have access to any existing files
or folders until the application’s Service Account is added as a collaborator.It is possible to
using the
as-user header or by requesting a
.Using a key pair
Follow the steps below if you would like to verify your application’s identity using a public and private key pair.Prerequisites
- A Platform Application using JWT authentication within the Developer Console
- A private key configuration file named
config.json, which can be downloaded from the configuration tab of the Developer Console - Ensure your application is within the Box Admin Console
1. Read JSON configuration
Yourconfig.json file contains the application’s private key and other
details necessary to authenticate. The following is an example of this file.
config.json
Parsing JSONIn some programming languages there is more than one way to read and parse
JSON from a file. Refer to guides on your preferred programming language for
more complete guides, including error handling.
2. Decrypt private key
To create the JWT assertion the application needs the private key from the configuration object. This private key is encrypted and requires a passcode to unlock. Both the encrypted key and passcode are provided in the configuration object.An alternative to loading private key from filethe application might not want to keep both the private key and password
stored on disk. An alternative option would be to pass in the password as an
environment variable, separating the private key from the token used to unlock
the key.
3. Create JWT assertion
To authenticate to the Box API the application needs to create a signed JWT assertion that can be exchanged for an Access Token. A JWT assertion is an encrypted JSON object, consisting of aheader, claims, and signature. Let’s start by creating the claims,
sometimes also referred to as the payload.
Next, these claims need to be signed using the private key. Depending on the
language and library used, the
header of the JWT is configured by defining the
encryption algorithm and the ID of the public key used to sign the claims.
Using JWT librariesSigning your own JWT can be a complicated and painful process. Luckily, the
hard work has already been done for you and libraries exist in pretty much
every language. Head over to for an overview.
