Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined RTM + Stream Channel Tokens + /getToken #38

Merged
merged 4 commits into from
Jul 26, 2023
Merged

Conversation

maxxfrazer
Copy link
Contributor

@maxxfrazer maxxfrazer commented Jul 26, 2023

Changes Made

  • Added a new function "getToken" to the Service struct to handle the "getToken" endpoint.
  • 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.

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.

…f channel name is provided. Added a new endpoint option for POST requests with bodies. tests added for everything.
@maxxfrazer maxxfrazer changed the title updated to go-tokenbuilder 1.3.0, which gives streamtokens with rtm i… Combined RTM + Stream Channel Tokens + /getToken Jul 26, 2023
@maxxfrazer maxxfrazer merged commit b0d693d into main Jul 26, 2023
1 check passed
@maxxfrazer maxxfrazer deleted the rtm-streamtoken branch August 18, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant