Authenticate a user

After a successful registration you would probably need to authenticate your user by using the registration email and password, so you will need to call:

private var listener: MBAuthApiAuthenticateListener 
private var email, password: String

MBurgerAuthTasks.authenticateUser(applicationContext, 
    listener,            //Listener for authentication
    email,               //Email of the user
    password);           //Password of the user

This method will return the jwt_token that will automatically be used in all subsequent calls until the app is uninstalled or the user is logged out in order to authenticate all API calls.

It will be automatically stored encrypted within your application, but if you need to save it for your purposes you can obtain it through the listener or with the โ€œactionโ€ mode inside the returned bundle with the key MBApiPayloadKeys.key_jwt_token.

If you wish to logout a user just callJava

MBurgerAuthTasks.clearAuthToken(applicationContext);

Make sure that your app UI will respond to the โ€œlogoutโ€ in a significative way.

Last updated