JavaScript

Generate a JWT

The Client SDK uses JWTs for authentication. The JWT identifies the user name, the associated application ID and the permissions granted to the user. It is signed using your private key to prove that it is a valid token.

NOTE: We'll be creating a one-time use JWT on this page for testing. In production apps, your server should expose an endpoint that generates a JWT for each client request.

Remember to replace the MY_APP_ID and MY_USER_NAME variables with your own values in the sections below. If you're testing with multiple users, generate multiple JWTs (changing the sub value each time).

Using the CLI

You can generate a JWT using the Nexmo CLI by running the following command:

nexmo jwt:generate ./private.key sub=MY_USER_NAME exp=$(($(date +%s)+21600)) acl='{"paths":{"/*/users/**":{},"/*/conversations/**":{},"/*/sessions/**":{},"/*/devices/**":{},"/*/image/**":{},"/*/media/**":{},"/*/applications/**":{},"/*/push/**":{},"/*/knocking/**":{}}}' application_id=MY_APP_ID

The generated JWT will be valid for the next 6 hours.

Using the web interface

Alternatively, you can use our online JWT generator with the following parameters to generate a JWT.

Application ID: MY_APP_ID
Sub: MY_USER_NAME
ACL:

{
  "paths": {
    "/*/users/**": {},
      "/*/conversations/**": {},
      "/*/sessions/**": {},
      "/*/devices/**": {},
      "/*/image/**": {},
      "/*/media/**": {},
      "/*/applications/**": {},
      "/*/push/**": {},
      "/*/knocking/**": {}
  }
}

Further information