> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qwacks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> The SDK signs your game in and manages player sessions for you.

Flock authentication has **two layers**, and the SDK handles both:

1. **Game** — the SDK authenticates your game with the credentials you configure once (API Key,
   Game ID, Game Version). Every request it makes is then identified as your game.
2. **Player** — players sign in through the SDK, which then manages their session automatically for
   the rest of play.

## Configure your game

Set your credentials in the **Qwacks → Flock** window (saved to `Assets/Resources/FlockConfig.asset`),
where the editor also **verifies the connection** and **resolves your Game Version** — both required
before the SDK can start (see [setup](/sdk/unity#setup)). With **Auto-Initialize On Load** the SDK
then authenticates as your game at startup; turn it off to call `FlockClient.Create` yourself. Either
way, reach everything through `FlockClient.Instance`.

## Sign in a player

Players sign in with one of several methods. Each resolves to the same player account, and the SDK
keeps them signed in afterward. Auth methods **throw** on failure.

<Tabs>
  <Tab title="Email / password">
    ```csharp theme={null}
    await FlockClient.Instance.Authentication.LoginWithEmailAsync(email, password);
    ```
  </Tab>

  <Tab title="Device ID">
    Frictionless guest sign-in keyed to the device:

    ```csharp theme={null}
    await FlockClient.Instance.Authentication.LoginWithDeviceAsync(deviceId);
    ```
  </Tab>

  <Tab title="Google / Apple / Steam / Facebook / Discord">
    Pass the token or ticket from the platform to the matching method —
    `LoginWithGoogleAsync`, `LoginWithAppleAsync`, `LoginWithSteamAsync`, `LoginWithFacebookAsync`,
    or `LoginWithDiscordAsync`.
  </Tab>
</Tabs>

The first sign-in registers the player automatically — there's no separate sign-up step (explicit
`RegisterWith…Async` methods also exist). Read `FlockClient.Instance.CurrentPlayerId` or handle
`FlockEvents.OnAuthenticated` afterward.

## Sessions are managed for you

Player sessions are short-lived under the hood, but **the SDK refreshes them automatically** — you
don't have to think about tokens or expiry. If a player needs to sign back in, the SDK raises
`FlockEvents.OnAuthExpired`.

<Tip>
  Auth methods throw `FlockException` on failure — wrap sign-in in `try/catch` so you can show a
  clean retry path (bad credentials, offline, etc.).
</Tip>
