ContentSync Logo

Sign Custom JWT

If you are using custom JWTs to make requests, you can use the following code for the JWT generation.

The code uses the following environment variable to sign JWTs:

  • CC_CLIENT_SECRET="<CLIENT id>=<CLIENT secret>"

  • CC_SPACE_ID="..."

  • CC_ENVIRONMENT_ID="..."

The provided code assumes you have the 'jsonwebtoken' package installed in your project.

Secrets are confidential, so only use this server-side and never expose a client secret to end users.

Update your local project using the Content Cloud CLI:

Terminal
# - Generate the schema for the REST API in TypeScript # - Download the generic REST client code # - Download the generic authentication code # Code is downloaded to the app/content-cloud folder. You may want to change this if you're using e.g. src/ instead of app/ for your project. content-cloud generate rest typescript -o app/content-cloud --client-code --client-auth-code

content-cloud/content-cloud-authentication.ts

View

To see how you can use this in your frontend app, check out this code example.