Auth

Get ID token with secret key

Changed on

This endpoint lets your application server (your back end) obtain a token that one of its clients (your frontend) can use to enter a Liveblocks room. You use this endpoint to implement your own application’s custom authentication endpoint. When using this endpoint to obtain ID tokens, you should manage your permissions by assigning user and/or group permissions to rooms explicitly, see our Manage permissions with ID tokens section.

Important: The difference with an access token is that an ID token doesn’t hold any permissions itself. With ID tokens, permissions are set in the Liveblocks back end (through REST API calls) and "checked at the door" every time they are used to enter a room. With access tokens, all permissions are set in the token itself, and thus controlled from your back end entirely.

Note: When using the @liveblocks/node package, you can use Liveblocks.identifyUser in your back end to build this request.

You can pass the property userId in the request’s body. This can be whatever internal identifier you use for your user accounts as long as it uniquely identifies an account. The property userId is used by Liveblocks to calculate your account’s Monthly Active Users. One unique userId corresponds to one MAU.

If you want to use group permissions, you can also declare which groupIds this user belongs to. The group ID values are yours, but they will have to match the group IDs you assign permissions to when assigning permissions to rooms, see Manage permissions with ID tokens).

Additionally, you can set custom metadata to the token, which will be publicly accessible by other clients through the user.info property. This is useful for storing static data like avatar images or the user’s display name.

post/identify-user

Request

  • Base URL: https://api.liveblocks.io/v2
  • URL: https://api.liveblocks.io/v2/identify-user
  • Auth: none declared

Request body

userIdstring required
organizationIdstring
groupIdsstring[]
userInfoobject

Example request

{
  "userId": "user-123",
  "organizationId": "acme-corp",
  "groupIds": [
    "marketing",
    "engineering"
  ],
  "userInfo": {
    "name": "bob",
    "avatar": "https://example.org/images/user123.jpg"
  }
}

Response

Success. Returns an ID token that can be used to enter one or more rooms.

tokenstring required

Example response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIi..."
}

Changes

    • breaking

      request body became required

    • breaking

      the request property became required

    • info

      api operation id post-identify-user removed and replaced with identify-user

    • info

      api tag Auth added

    • info

      api tag Authentication removed

    • info

      the response property became required for the status

    • warning

      removed the request property

    • info

      added the new optional request property