Authentication
How to authenticate with Reactive's services.
Public request JWT authentication
Your app's users can interact with Reactive's services using JWT authentication. First, users need to get a JWT token for them to authenticate.
Creating a JWT Token for your user
This action creates a JWT token for your user to interact with Reactive's services. This token expires in 30 minutes. When your token expires, create a new token to keep using Reactive's services.
Request:
POST
https://authentication-token.reactive.live/api/v1/token
Body:
Name | Type | Required | Description |
---|---|---|---|
stream_id | string | Yes | Id of the stream the user is viewing. |
unique_user_identifier | string | Yes | A unique identifier for this user. |
For authenticated users, we recommend setting the unique_user_identifier
as the user's id. For unauthenticated users, we recommend generating a fingerprint using a library like client.js.
Example command:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"stream_id": "6935357a-8d71-45f2-9a0f-ddaed705b43a", "unique_user_identifier": "AB35457a-8d71-45f2-BE2F-ddaed705b43a"}' \
https://authentication-token.reactive.live/api/v1/token
Response:
HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpcCI6IjEwNC4xNjIuOTcuMjgiLCJhdWQiOiI2OTM1MzU3YS04ZDcxLTQ1ZjItOWEwZi1kZGFlZDcwNWI0M2EiLCJzdWIiOiJBQjM1NDU3YS04ZDcxLTQ1ZjItQkUyRi1kZGFlZDcwNWI0M2EiLCJpc3MiOiJSZWFjdGl2ZSIsImlhdCI6MTYzNDkzNTQ5NCwiZXhwIjoxNjM0OTM2MDk0LCJqdGkiOiIwNzRlNDA0MS02MDg0LTQyOTItOTk2MC1jMTBlNWE1YzAwMjgifQ.o-pkrvzbTSVlzGixknSQvX1cwH1UIpx3R_fzmMpn3R8"
}
Authenticating with public JWT authentication
To use public JWT authentication when making requests to the Reactive API, include the JWT token in the Authorization header prefixed with the string literal Bearer
. For example:
curl -X POST \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpcCI6IjEwNC4xNjIuOTcuMjgiLCJhdWQiOiI2OTM1MzU3YS04ZDcxLTQ1ZjItOWEwZi1kZGFlZDcwNWI0M2EiLCJzdWIiOiJBQjM1NDU3YS04ZDcxLTQ1ZjItQkUyRi1kZGFlZDcwNWI0M2EiLCJpc3MiOiJSZWFjdGl2ZSIsImlhdCI6MTYzNDkzNTQ5NCwiZXhwIjoxNjM0OTM2MDk0LCJqdGkiOiIwNzRlNDA0MS02MDg0LTQyOTItOTk2MC1jMTBlNWE1YzAwMjgifQ.o-pkrvzbTSVlzGixknSQvX1cwH1UIpx3R_fzmMpn3R8" \
https://view-counts.reactive.live/api/v1/view-counts/6935357a-8d71-45f2-9a0f-ddaed705b43a
Unauthenticated responses that are denied permission will result in an HTTP 401 Unauthorized
response.