Skip to content

v1.4.1

Compare
Choose a tag to compare
@maxxfrazer maxxfrazer released this 26 Jul 15:31
· 37 commits to main since this release
b0d693d

Changes Made

  • Added a new function "getToken" to the Service struct to handle the "getToken" endpoint (POST requests).
  • Implemented logic to parse the request body into a TokenRequest struct to process token generation requests.
  • Implemented functions to generate RTC tokens, RTM tokens, and chat tokens based on the TokenRequest.
  • updated to go-tokenbuilder 1.3.0, which gives streamtokens with rtm if channel name is provided.

New Endpoint Details

Endpoint: /getToken

HTTP Method: POST

Request Payload:

{
  "tokenType": "rtc",       // The token type: "rtc", "rtm", or "chat"
  "channel": "channel123",  // The channel name (used for RTC and RTM tokens)
  "role": "publisher",      // The role of the user for RTC tokens (publisher or subscriber)
  "uid": "123",         // The user ID or account (used for RTC, RTM, and some chat tokens)
  "expire": 3600            // The token expiration time in seconds (used for all token types)
}

Response

Upon successful generation of the token, the API will respond with an HTTP status code of 200 OK, and the response body will contain the token in a JSON key "token".

{
  "token": "007hbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZG1pbiIsInN1YiI6InVzZXIxMjMiLCJpYXQiOjE2MzEwNTU4NzIsImV4cCI6MTYzMTA1OTQ3Mn0.3eJ-RGwIl2ANFbdv4SeHtWzGiv6PpC3i0UqXlHfsqEw"
}

If there are validation errors in the request or issues during token generation, the endpoint responds with an appropriate error message and the corresponding status code.


#38

Full Changelog: v1.4.0...v1.4.1