Skip to content

Latest commit

 

History

History
51 lines (32 loc) · 2.06 KB

File metadata and controls

51 lines (32 loc) · 2.06 KB
code type title description
true
page
login
Authenticate a user

login

Authenticates a user.

If this action is successful, then the jwt property of this class instance is set to the new authentication token.

All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the logout action is called, or the jwt property is manually set to another value.

Arguments

login(strategy, [credentials], [expiresIn]);

Arguments Type Description
strategy
string
Name of the strategy to use
credentials
object
 Credentials for the strategy
expiresIn
string
 Expiration time in ms library format. (e.g. 2h)

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 in 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.

Resolves

The login action returns the encrypted JSON Web Token.

Usage

Local strategy login example

<<< ./snippets/login.js