SDK
SDK Javascript v5.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

checkToken #

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.

This method is non-queuable, meaning that during offline mode, it will be discarded and the callback return an error.

checkToken(token, callback) #

ArgumentsTypeDescription
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 #

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.

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle.checkToken(token, function (err, res) {
  // ...
});
// Using promises (NodeJS only)
kuzzle.checkTokenPromise(token)
  .then(res => {
    // ...
  });