Skip to main content

Generate your JWT Token

This tutorial will introduce you to the Reporting API, DoorDash's API for requesting operational and financial data.

Table of contents​

  1. Sign into the Developer Portal
  2. Create an access key
  3. Install pre-requisites and create a project
  4. Make a JWT

Sign into the Developer Portal​

Go to the Developer Portal using the link in the top right corner of this page. If you already have a DoorDash account, enter your email and password and sign in; if not, or if you want to use a different account for development, click Sign Up and follow the process to create an account.

A screenshot of the Developer Portal sign-in screen

Create an access key​

In the left navigation, click Credentials.

A screenshot of the Developer Portal left navigation menu with the Credentials navigation item highlighted

On the Credentials page, click the plus (+) icon in the center of the page to create a new access key. You'll use this access key to create a JSON Web Token (JWT) that you can use to make requests to the Drive API.

A screenshot of the Credentials page with the button for creating a new access key highlighted

Name your key test-app and click Create Access Key.

A screenshot of the modal for creating an access key

Click Copy to copy the access key to your clipboard and then paste it somewhere where you can access it later in the tutorial.

A screenshot of an access key

Install pre-requisites and create a project​

If you don't already have them, install Node.js and npm.

Then, create a directory for your project called test-app and then create a new file named app.js.

Make a JWT​

Prerequisites​

Before getting started, ensure you have created and saved an access key from the Developer Portal.

To continue, you will need: developer_id, key_id and signing_secret

Install a JWT library​

Most programming languages provide support for creating JSON Web Tokens (JWTs) either directly in the language or as a package. Select your language and then follow the instructions to install the package, if needed.

Open a terminal and navigate to your project directory, then run:

npm install jsonwebtoken

Generate a JWT​

JWTs are created using an access key. Use these code snippets to generate a correctly-formatted JWT from your access key.

Copy the code snippet below into your project file. Replace PASTE_YOUR_ACCESS_KEY_HERE with your access key.

const jwt = require('jsonwebtoken')

const accessKey = PASTE_YOUR_ACCESS_KEY_HERE

const data = {
aud: 'doordash',
iss: accessKey.developer_id,
kid: accessKey.key_id,
exp: Math.floor(Date.now() / 1000 + 300),
iat: Math.floor(Date.now() / 1000),
}

const headers = { algorithm: 'HS256', header: { 'dd-ver': 'DD-JWT-V1' } }

const token = jwt.sign(
data,
Buffer.from(accessKey.signing_secret, 'base64'),
headers,
)

console.log(token)

Then, test your code. In your terminal, run:

node app.js

If you were successful, you should see output like this:

A screenshot of a terminal showing a successful run of the program