# Authenticating Users

Before we can do any sort of matchmaking, we need to login with the **Online Subsystem** first. Kronos features an **automated user authentication** process, so we do not need to do anything. Authentication is entirely handled by the `KronosUserManager` class.

## Starting Authentication

By default authentication will start automatically when the "Game Default Map" - set in your Project Settings - is opened.

<figure><img src="/files/vhne25RfTXZnbm2ZX9Rp" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can override which map is considered as the game default map from the plugin's settings. This is useful if you want to have a dedicated "login" map.
{% endhint %}

The user will be authenticated every time when loading the game default map, even if authentication was completed before. We do this to confirm that the user didn't lose his login status while he was away (e.g. playing in a match).

## Overriding Login Parameters

During authentication the user will be logged in with the **Online Subsystem**. Different Online Subsystems require different inputs when logging in.

{% tabs %}
{% tab title="Null Subsystem" %}
The **Null Online Subsystem** requires a login id. By default the plugin will use the local users' id so you do not have to do anything. Works out of the box.
{% endtab %}

{% tab title="Steam Subsystem" %}
The **Steam Online Subsystem** doesn't require any inputs. Works out of the box.
{% endtab %}

{% tab title="EOS Subsystem" %}
The **EOS Online Subsystem** requires a login type. By default the `AccountPortal` login type is used. With this method, a browser window will open and the user will be asked to input their Epic account information. For more information about the different login types, please refer to the **Login section** of the EOS documentation: [Online Subsystem EOS Plugin in Unreal Engine](https://docs.unrealengine.com/5.3/en-US/online-subsystem-eos-plugin-in-unreal-engine/).
{% endtab %}
{% endtabs %}

To change the default login parameters, create a new blueprint from the `KronosUserManager` class and override the `GetLoginCredentials` function.

<figure><img src="/files/bpBOggmflbj9h4MHD67S" alt=""><figcaption></figcaption></figure>

Now go to **Project Settings -> Kronos Matchmaking** and set the "User Manager Class" to your custom blueprint that you just created.

## Authentication Widget

While authentication is in progress, a widget will be displayed showing the current auth state. During this time the user should be unable to interact with the game.

In case user authentication fails, the authentication widget will switch over to a failure screen displaying the error message to the user. From there the user can either retry authentication or quit the game.

Please refer to the [**Customizing The Auth Widget**](/kronos-matchmaking/usage/authentication/customizing-the-auth-widget.md) documentation page for more information about auth widget customization.

## Entering The Game

When **authentication is complete**, the `OnEnterGame` event of the `KronosOnlineSession` will be called. Think about this as passing the "login screen" of the game. You can display the main menu widget from here, add popups to the screen, or travel to a new map if needed.

## Disable Automatic Authentication

You may want to have your authentication set up in a way that initially when the game loads, the user would have to press a key to enter the game. This is the "Press any key to continue" screen you've probably seen in a lot of games.

You can disable automatic user authentication in the plugin's settings. When disabled, the game has to call the `AuthenticateUser` function of the `KronosUserManager` manually.

The `KronosOnlineSession` class has a convenient `OnGameDefaultMapLoaded` event which you can use to handle user authentication. When the event is called, check if the user is currently authenticated and decide what to do. If the user is already authenticated, then he is returning from a match so you should authenticate to confirm his login status. If the user is not authenticated, then its the users first time loading the game which means you can wait for an input.

## Passthrough Authentication

In case you want to allow a third party program or plugin to handle authentication instead of Kronos, go to **Project Settings -> Kronos Matchmaking** and enable "Authentication Is Passthrough". If this option is enabled, the user will not be logged in with the Online Subsystem during user authentication.

{% hint style="info" %}
The plugin internally tracks whether the user was authenticated or not. This means that even if authentication is not handled by Kronos you will still have to call `AuthenticateUser` to ensure that everything work correctly.
{% 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://horizongames.gitbook.io/kronos-matchmaking/usage/authentication/authenticating-users.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.
