Test Token Provider API

For more information about the token auth process, please refer to the authentication docs. This service is turned off by default, you can switch it on from the Chatkit instance settings in your dashboard.

While perfect for getting up and running, the test token provider should only be used for testing purposes and disabled before your Chatkit application is in production.

Endpoint

Test Token Provider requests should be sent to

https://us1.pusherplatform.io/services/chatkit_token_provider/v1/:instance_id

appended with the right endpoint for the resource you're interested in, in this case the /token endpoint. You can get your pre-built endpoint from your dashboard settings tab where you enable the test token provider.

Create a Token

POST /token

Used to generate valid Chatkit tokens for your app. Supply it with a grant type and user id to generate a new token.

You are able to use either a query string or request body, but please only use one or the other.

Use a Query String

A query string with the following required fields:

  • user_id: your desired user id

Use a Request Body

A JSON object with the following keys

  • grant_type (string | required): Use "client_credentials".
  • user_id (string | required): name of the new user, must be < 60 characters with no spaces.

JSON format

1
2
3
4
{
  "grant_type": "client_credentials",
  "user_id": "phil_usher"
}
Response Body

A JSON object containing the following keys

  • access_token (string): access JWT.
  • user_id (string): user_id included as the token subject.
  • token_type (string): type of token returned (will be "access_token").
  • expires_in (int): expiry time of the token.
1
2
3
4
5
6
{
  "access_token":"your_token_here",
  "user_id":"hugh_mungus",
  "token_type":"access_token",
  "expires_in":"1504801895"
}
Response Codes
  • 200 if successful
  • 400 if user error
  • 404 if the instance locator not found (make sure the test token provider is turned on in the application dashboard)
  • 5xx if server error