SDK
SDK Android v3.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 #

kuzzle.checkToken("some jwt token", new ResponseListener<TokenValidity>() {
  @Override
  public void onSuccess(TokenValidity tokenInfo) {
    if (tokenInfo.isValid()) {
      // tokenInfo.getExpiresAt() returns the expiration timestamp
    }
    else {
      // tokenInfo.getState() returns the invalidity reason
    }
  }
});