SDK
SDK Dart v2.x
2

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 authentication token property is manually unset.

Arguments #

Copied to clipboard!
Future<String> login(String strategy, Map<String, dynamic> credentials,
          {String expiresIn})

Argument Type Description
strategy
String
Strategy to use
credentials
Map<String, dynamic>
Hashmap representing the credentials
expiresIn
String
Token duration

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 a Hashmap with the following properties:

Property Type Description
_id
String
User's kuid
jwt
String
Encrypted authentication token, that must then be sent in the requests headers or in the query
expiresAt
int
Token expiration date, in Epoch-millis (UTC)
ttl
int
Token time to live, in milliseconds

Once auth:login has been called, the returned authentication token is stored by the SDK and used for all the subsequent API call, ensuring they are properly authenticated.

Usage #

Copied to clipboard!
final result = await kuzzle
  .auth
  .login(
    'local',
    {
      'username': 'foo',
      'password': 'bar'
    }
  );