Authentication

Sariska utilizes JSON Web Tokens (JWTs) to securely authenticate users and devices. JWTs are a standardized, structured, and self-contained method for conveying information between clients as JSON objects. They serve as a mechanism for asserting claims exchanged between two parties. In the context of a JWT, a claim is a declaration about a company or user, accompanied by additional metadata about the token itself. The payload, which is maintained in JSON format, contains a set of claims. JWTs are digitally signed and encrypted for enhanced security.

Sariska generates these tokens on its servers. A single token can be used to access all Sariska services.

async function fetchToken () {
   const payload = {
       method: "POST",
       headers: {
           'Content-Type': 'application/json"
       },
       body: JSON.stringify({
            apiKey: "{your-api-key}",
            user: {  // optional
                id: "ytyVgh",
                name: "Nick",
                email: "nick@gmail.com",
                avatar: "https://some-storage-location/nick.jpg",
                moderator: true
                // If participant is moderator set to true, otherwise leave blank.
                // Sariska will automatically appoint the first participant as moderator if the moderator leaves.
            }
       })
   };

   try {
       const response = await fetch("https://api.sariska.io/api/v1/misc/generate-token", payload);
       if (response.ok) {
          const json = await response.json();
          const token = json.token;
          return token;
       }
   } catch (error) {
      console.log(error);
   }
}
await fetchToken();

Last updated