// 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)

Arguments Type Description
token string The token to check
callback function Callback 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

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