# 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:

```kotlin
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.

&#x20;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

```kotlin
MBurgerAuthTasks.clearAuthToken(applicationContext);
```

{% hint style="warning" %}
Make sure that your app UI will respond to the “logout” in a significative way.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mburger.cloud/android-docs/auth-feature/authenticate-a-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
