await FlockClient.Instance.Authentication.LoginWithEmailAsync(email, password);Debug.Log($"Signed in as {FlockClient.Instance.CurrentPlayerId}");
A new player must register before they can log in.LoginWith…Async never creates an
account — it only signs in one that already exists. Calling it for someone who has never
registered fails with player.invalid_login_credentials.This catches people most often on device sign-in, where it feels like a guest flow that
should just work:
// First launch on this device — creates the account AND signs in.await FlockClient.Instance.Authentication.RegisterWithDeviceAsync(deviceId);// Every launch after that.await FlockClient.Instance.Authentication.LoginWithDeviceAsync(deviceId);
If you’d rather not track which one to call, register first and fall back. Registering an
identity that already has an account does not throw — it returns null and leaves the
player signed out, so you must follow it with a login:
FlockAuthProvider auth = FlockClient.Instance.Authentication;// null means "this device already has an account" — not an error, but not signed in either.if (await auth.RegisterWithDeviceAsync(deviceId) == null) await auth.LoginWithDeviceAsync(deviceId);
A successful RegisterWith…Async also signs the player in, so there is no second call on the
happy path. If you do get the order wrong, the exception says so and names the method to call
instead; see Error handling.
Each method is an async node under Flock | Auth with On Success and On Failure pins, or a
call on the auth provider in C++. The SDK exchanges the credential your platform SDK produced for
a Flock session.
Login and register are separate calls — registering does not sign the player in, so follow it
with a login. Facebook and Discord are login-only; an account must already exist.Registering an identity that already has an account is reported as a success with
bAlreadyRegistered set, so you can send the player to a login rather than show them a failure.See the Unreal SDK guide for the full provider table.
The SDK keeps the player signed in and refreshes their session automatically — you never handle
tokens or expiry yourself. If a player needs to re-authenticate, the SDK raises
FlockEvents.OnAuthExpired.