SDK
SDK C++ v1.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.

This SDK has been deprecated because of stability issues. It is not advised to use it in a production environment.

login #

Authenticates a user.

If this action is successful, all further requests emitted by this SDK instance will be in the name of the authenticated user, until either the authenticated token expires, the logout action is called, or the jwt property is manually unset.

Arguments #

Copied to clipboard!
std::string login(const std::string& strategy, const std::string& credentials);

std::string login(
    const std::string& strategy,
    const std::string& credentials,
    int expiresIn);

Arguments Type Description
strategy
const std::string&
Strategy to use
credentials
const std::string&
JSON string representing the credentials
expiresIn
int
Expiration time, in milliseconds

strategy #

The name of the authentication strategy used to log the user in.

Depending on the chosen authentication strategy, additional credential arguments may be required. The API request example on this page provides the necessary arguments for the local authentication plugin.

Check the appropriate authentication plugin documentation to get the list of additional arguments to provide.

expiresIn #

The default value for the expiresIn option is defined at server level, in Kuzzle's configuration file.

Return #

Returns the encrypted JSON Web Token. Once auth:login has been called, the returned JWT is stored by the SDK and used for all the subsequent API call, ensuring they are properly authenticated.

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"})");
  std::cout << "Success" << std::endl;
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}