Creating a JWT
Follow these steps to create a JWT.1
Create a JWT header with this format:
{"alg": "RS256", "typ": "JWT"}2
Base64url encode the JWT header.
3
Construct a JSON Claims Set for the JWT with the following parameters.
| Parameter | Description |
|---|---|
tokenType | powered-by (This JWT token is type powered-by.) |
iat | The time the JWT is issued, expressed as the number of seconds from 1970-01-01T0:0:0Z measured in UTC. |
exp | The date and time at which the token expires, expressed as the number of seconds from 1970-01-01T0:0:0Z measured in UTC. |
iss | The account Id of the parent account. |
sub | The account Id of the child account (optional for Create Account and List Connections). |
The following is an example JSON Claim Set for the JWT:
4
Base64url encode the JSON Claims Set without any line breaks.
5
Create a string for the encoded JWT Header and the encoded JWT Claims Set in the following format:
6
Sign the token with your private key and format the token.
7
Register the public key certificate in Privacy-Enhanced Mail (PEM) format in the management account. Open a support ticket with Connect AI to register the public key.
Generating JWT Keys
A JWT requires a public and private key in PEM format. You sign the JWT with your private key and you register the public key with CData. There are several ways to generate JWT keys. The examples below useopenssl.
Generating a Private Key
The following example shows how to generate the JWT private key usingopenssl:
private.key. Do not share this file with anyone!
Generating a Public Key
Use the private key to generate the public key. Inopenssl, the command is as follows:
public.key, which you need to share with CData.
Code Samples
Click the relevant tab for the code sample for creating a JWT.- Java
- Python
- C#
- node.js
Creating a JWT in Java: