SDK Golang v1.x

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.

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!
func (a *Auth) Login(
  strategy string,
  credentials json.RawMessage,
  expiresIn *int) (string, error)
Arguments Type Description Required
Name of the strategy to use yes
Credentials for that strategy yes
Expiration time, in milliseconds no

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.

Return #

The login action returns an encrypted JSON Web Token, that must then be sent in the requests headers.

Usage #

Copied to clipboard!
_, err := kuzzle.Auth.Login("local", json.RawMessage("{\"username\":\"foo\",\"password\":\"bar\"}"), nil)
if err != nil {
} else {