Digital Samba Embedded
  • Introduction
  • SDK
    • DigitalSambaEmbedded class
    • Methods
      • addCustomTile()
      • removeCustomTile()
      • addFrameEventListener()
      • addImageToWhiteboard()
      • addTileAction()
      • addUICallback()
      • allowBroadcast()
      • allowScreenshare()
      • changeBrandingOptions()
      • changeLayoutMode()
      • changeRole()
      • changeToolbarPosition()
      • closeLibraryFile()
      • closeWhiteboard()
      • createWhiteboard()
      • configureCaptions()
      • configureVirtualBackground()
      • disableAudio()
      • disableVideo()
      • disableVirtualBackground()
      • disallowBroadcast()
      • disallowScreenshare()
      • enableAudio()
      • enableVideo()
      • enableVirtualBackground()
      • endSession()
      • featureEnabled()
      • hideCaptions()
      • hideToolbar()
      • leaveSession()
      • listUsers()
      • load()
      • lowerHand()
      • muteFrame()
      • maximizeLocalTile()
      • maximizeUser()
      • minimizeLocalTile()
      • minimizeContent()
      • minimizeUser()
      • off()
      • on()
      • once()
      • openLibraryFile()
      • openWhiteboard()
      • pinUser()
      • raiseHand()
      • removeFrameEventListener()
      • removeTileAction()
      • removeUICallback()
      • removeUser()
      • requestMute()
      • requestToggleAudio()
      • requestUnmute()
      • showCaptions()
      • showToolbar()
      • startRecording()
      • startScreenshare()
      • stopRecording()
      • stopScreenshare()
      • toggleAudio()
      • toggleCaptions()
      • toggleMuteFrame()
      • toggleToolbar()
      • toggleVideo()
      • toggleWhiteboard()
      • toggleLibraryFile()
      • unmuteFrame()
      • unpinUser()
    • Events
      • activeSpeakerChanged
      • appError
      • appLanguageChanged
      • audioDisabled
      • audioEnabled
      • captionsDisabled
      • captionsEnabled
      • captionsFontSizeChanged
      • captionsSpokenLanguageChanged
      • chatMessageReceived
      • featureSetUpdated
      • frameLoaded
      • handRaised
      • handLowered
      • layoutModeChanged
      • mediaDeviceChanged
      • permissionsChanged
      • recordingFailed
      • recordingStarted
      • recordingStopped
      • roleChanged
      • roomStateUpdated
      • screenshareStarted
      • screenshareStopped
      • sessionEnded
      • speakerStoppedTalking
      • userJoined
      • userLeft
      • usersUpdated
      • videoDisabled
      • videoEnabled
      • virtualBackgroundChanged
      • virtualBackgroundDisabled
    • Properties
      • features
      • localUser
      • permissionManager
      • roomState
  • REST API
    • Rate limiting
    • Pagination
    • Default room settings
      • List
      • Edit
    • Rooms
      • Create
      • Edit
      • List
      • Delete
        • All resources
        • Concrete resource
      • Files
      • Chat
        • List
        • Export
      • Questions & Answers
        • List
        • Export
      • Transcription
        • List
        • Export
        • Start
        • Stop
    • Sessions
      • List
      • End
      • Delete resources
        • All resources
        • Concrete resource
      • Transcripts
      • Summary (AI)
    • Participants
      • List
    • Roles and permissions
      • Permissions
      • Create
      • Edit
      • List
      • Delete
    • Live usage
      • Rooms
      • Participants
    • Statistics
      • Current period
      • Team
      • Room
    • Tokens
      • Properties
      • Create
    • Recordings
      • List
      • Download
      • Start
      • Stop
      • Delete
      • Archive
      • Unarchive
    • Polls
      • Create
      • Edit
      • List
      • Delete
      • Export
      • Results
    • Content Library
      • Create
      • Edit
      • List
      • Delete
      • Folders
        • Create
        • Edit
        • List
        • Delete
      • Files
        • Upload
        • Webapps
        • Whiteboards
        • Edit
        • List
        • Delete
    • Telephony
      • Participant Join
      • Participant Leave
    • Webhooks
      • Payload structure
      • Create
      • Edit
      • List
      • Delete
    • Scribe / Postman docs
  • Dashboard docs
  • LTI docs
Powered by GitBook
On this page
  1. REST API
  2. Tokens

Create

PreviousPropertiesNextRecordings

Last updated 4 months ago

You can either create the token with your favourite JWT library or you can rely on our to 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.

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 - there are plenty of available libraries for each possible language.

The Java example is using the popular open source 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);
$developerKey = 'YOUR_DEVELOPER_KEY_FROM_THE_DASHBOARD';
$teamId = 'YOUR_TEAM_ID_FROM_THE_DASHBOARD';
$roomId = 'YOUR_ROOM_NAME_OR_ID';
$username = 'John Smith';

// Create token header as a JSON string
$header = json_encode(['typ' => 'JWT', 'alg' => 'HS256']);

// Create token payload as a JSON string
$payload = json_encode([
    'td' => $teamId,
    'rd' => $roomId,
    'u' => ''.$username.'',
    'role' => 'moderator'
]);
                        
// Encode Header to Base64Url String
$base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($header));

// Encode Payload to Base64Url String
$base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($payload));

// Create Signature Hash
$signature = hash_hmac('sha256', $base64UrlHeader . "." . $base64UrlPayload, $developerKey, true);

// Encode Signature to Base64Url String
$base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature));

$token = $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature;
REST API
JWT site
java-jwt