checkToken

Checks a JWT Token's validity.

Signature

Copied to clipboard!
kuzzleio::token_validity* checkToken(const std::string& token);

Arguments

Arguments Type Description
token
string
JWT token

Return

A pointer to a token_validity struct which has:

Name Type Description
valid
bool
Token validity
state
const char*
Explain why the token is invalid
expires_at
unsigned long long
Token expiration timestamp

Exceptions

Throws a kuzzleio::KuzzleException if there is an error. See how to handle error.

Usage

Copied to clipboard!
try {
  std::string jwt = kuzzle->auth->login(
    "local",
    R"({"username":"foo","password":"bar"})");

  kuzzleio::token_validity* res = kuzzle->auth->checkToken(jwt);

  if (res->valid)
    std::cout << "Success" << std::endl;
  else
    std::cerr << res->state << std::endl;
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}