# Authentication and User Management

Every user on your platform must have a corresponding user ID on the GIZO platform. This association is established using the createUser method provided by the GIZO SDK.

## &#x20;Procedure of Authentication of a User

1. Use your client ID and client secret to authenticate and manage your company's users with the GIZO SDK.

```kotlin
Gizo.setToken(<clientId>, <clientSecret>);
```

Go to step 4 if the user has already a user ID on the GIZO platform. Otherwise,

2. Use the createUser method to generate a new user ID:

```kotlin
CoroutineScope(Dispatchers.IO).launch {
    val userId = Gizo.createUser();
    if (userId != -1) {
        Log.d("tag", userId.toString());
    }
}
```

3. Store the generated ID in your database, so you can use the next time.
4. Use the GIZO user ID associated to your user to authenticate your user. This can be done through the setUserId method:

```kotlin
CoroutineScope(Dispatchers.IO).launch {
    val status = Gizo.setUserId(<gizoUserId>)
    Log.d("tag", status.toString());
}
```

<mark style="color:red;">NOTE: It is recommended to store the GIZO User IDs in you database to correlate your app user IDs to their respective GIZO user IDs</mark>


---

# 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.artificient.de/usage/android/authentication-and-user-management.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.
