// Using callbacks (NodeJS or Web Browser)
kuzzle.checkToken(token, function (err, res) {
  // ...

// Using promises (NodeJS only)
  .then(res => {
    // ...
kuzzle.checkToken("some jwt token", new ResponseListener<TokenValidity>() {
  public void onSuccess(TokenValidity tokenInfo) {
    if (tokenInfo.isValid()) {
      // tokenInfo.getExpiresAt() returns the expiration timestamp
    else {
      // tokenInfo.getState() returns the invalidity reason

$result = $kuzzle->checkToken('some jwt token');

$result = [
  'expiresAt' => 1468257834099, //timestamp in milliseconds
  'valid' => true

Callback response if the token is valid:

  "expiresAt": 1454588077399,
  "valid": true

Callback response if the token is invalid:

  "valid": false,
  "state": "<invalidity reason>"

Checks the validity of a JSON Web Token.

checkToken(token, callback)

tokenstringThe token to check
callbackfunctionCallback handling the response

Note: this method sends an unauthenticated API call to Kuzzle, meaning it ignores the JWT Token property, even if it has been set.

Callback response

A JSON object with a valid boolean property.
If the token is valid, a expiresAt property is set with the expiration timestamp. If not, a state property is set explaining why the token is invalid.