Create

You can either create the token with your favourite JWT library or you can rely on our REST API arrow-up-rightto create it for you. Note that if you need to create a lot of tokens at the same time, you may want to use a JWT library, since our API is rate-limited and you cannot execute thousands of requests per second.

circle-info

Note the below examples are just for guidance - you are free to use any JWT library you are comfortable with or which your frameworks support. As you can see on the official JWT sitearrow-up-right - there are plenty of available libraries for each possible language.

The Java example is using the popular open source java-jwtarrow-up-right library.

The PHP example doesn't use external libraries, so it is a little bit more verbose.

String developerKey = "YOUR_DEVELOPER_KEY_FROM_THE_DASHBOARD";
String teamId = "YOUR_TEAM_ID_FROM_THE_DASHBOARD";
String roomId = "YOUR_ROOM_NAME_OR_ROOM_ID";
String username = "John Smith";

Algorithm algorithm = Algorithm.HMAC256(developerKey);
String token = JWT.create()
    .withClaim("td", teamId)
    .withClaim("rd", roomId)		
    .withClaim("u", username)	    
    //.withClaim("ud", "ABC1234567254435")
    //.withClaim("role", "moderator")
    //.withIssuedAt(new Date())
    //.withNotBefore(new Date(System.currentTimeMillis() + 3600000))
    //.withExpiresAt(new Date(System.currentTimeMillis() + (3600000 * 2)))
    .sign(algorithm);

Last updated