# Client & Authentication

Before joining a call, it is necessary to set up the video client. Here's a basic example:

1. Create the `IStreamVideoClient` instance

   ```csharp
   _client = StreamVideoClient.CreateDefaultClient();
   ```

2. Connect user to the Stream API

   ```csharp
   var authCredentials = new AuthCredentials("api-key", "user-id", "user-token");
   await _client.ConnectUserAsync(authCredentials);
   ```

- The **API Key** can be found in your Stream dashboard.
- The **User** can be either authenticated, anonymous or guest.
- Note: You can store custom data on the user object, if required.

Here's a complete example of a MonoBehaviour that initiates the client and connects to the Stream API:

```csharp
using System;
using StreamVideo.Core;
using StreamVideo.Libs.Auth;
using UnityEngine;

public class VideoClient : MonoBehaviour
{
    async void Start()
    {
        _client = StreamVideoClient.CreateDefaultClient();

        try
        {
            var authCredentials = new AuthCredentials("api-key", "user-id", "user-token");
            await _client.ConnectUserAsync(authCredentials);

            // After we awaited the ConnectUserAsync the client is connected
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }

    private IStreamVideoClient _client;
}
```

### Generating a token

Tokens provide a way to authenticate a user or give access to a specific set of calls. They're similar to passwords but offer more flexibility, allowing you to set the expiry date. For security reasons, tokens need to be generated server-side.
Typically, you integrate this into the part of your codebase where you login or register users. You can use our server-side SDKs to easily add support for this. For detailed instruction, refer to our server-side docs on [installation](/video/docs/api/#installation/) and [creating-users-and-user-tokens](/video/docs/api/#creating-users-and-user-tokens/).

Here's a valid user and token to help you get started on the client side before integrating with your backend API:

<token-snippet app='meeting' style='credentials'></token-snippet>

### Client options

Here's an example showing how you can pass configuration options through the `StreamClientConfig` instance passed to the `CreateDefaultClient` method:

```csharp
var config = new StreamClientConfig
{
    // Enabling Debug level logging can be helpful during development
    LogLevel = StreamLogLevel.Debug,
    Audio =
    {
        // Increase audio quality in exchange for higher bandwidth
        EnableRed = false,

        // DTX encodes silence at lower bitrate. This can save bandwidth
        EnableDtx = false
    }
};
_client = StreamVideoClient.CreateDefaultClient(config);
```


---

This page was last updated at 2026-07-13T13:43:25.407Z.

For the most recent version of this documentation, visit [https://getstream.io/video/docs/unity/guides/client-auth/](https://getstream.io/video/docs/unity/guides/client-auth/).