Skip to main content
Authentication & Players

Not translated yet — showing English.

User Login

Every player starts as an anonymous player, and signs in with a provider when they want to keep their account. PlayServ.Connect() creates the anonymous player on the first launch and restores it on the next ones. Signing in with Apple, Google, Facebook, Epic or Steam then attaches that provider to the same player, so nothing the player did as a guest is lost.

using Playserv.Identity;
using Playserv.Wrapper;
using UnityEngine;

// After PlayServ.Connect(): attach Google to the current player.
var result = await PlayServAuth.LoginExternalAsync(PlayServExternalIdentityProof.FromGoogleIdToken(idToken));
if (result.Status == PlayServAuthOperationStatus.Success)
    Debug.Log($"Signed in as {PlayServAuth.PlayerId}");

The providers your players can use are switched on for the project in SSO & Auth.


Anonymous players

When the game connects with a client key, the SDK signs in an anonymous player: a new one on the first launch, the saved one after that. Nothing else is needed. See Connection & Session for how the session is kept.

PropertyWhat it tells you
PlayServAuth.IsLoggedInWhether a player is signed in.
PlayServAuth.PlayerIdThe player's PlayServ ID, plr_…. It stays the same when providers are added.
PlayServAuth.SessionKindAnonymous, or Registered once a provider is attached. None before sign-in.
PlayServAuth.CurrentSession.LinkedProvidersThe providers attached to the player.

Set AnonymousDisplayName on the SDK settings from code, before connecting, to name a new anonymous player, including the one created after a sign-out. It doesn't rename an existing one.


Sign in with a provider

Get the player's token from the provider, turn it into a proof, and pass it to LoginExternalAsync.

ProviderProofCompanion package
AppleFromAppleIdToken(idToken, nonce)com.playserv.apple-signin, using Sign in with Apple on iOS
GoogleFromGoogleIdToken(idToken, nonce)com.playserv.google-signin, on top of the Google Sign-In plugin for Unity
FacebookFromFacebookLimitedLoginToken(token, nonce); the nonce is requiredcom.playserv.facebook-login, using the Meta SDK's Limited Login
EpicFromEpicExternalAuthToken(token)com.playserv.epic-auth, using the EOS plugin for Unity
SteamFromSteamTicket(ticket)com.playserv.steam-auth, using Steamworks.NET

The companion packages are optional helpers that get the provider's token for you; you can also build the proof from a token you already have. Install and switch them on in Tools ▸ PlayServ ▸ Settings, under the SDK module settings. Add .WithDisplayName(name) to a proof to name the player when the account is first created or linked.

LoginExternalAsync(proof, mode) decides what happens to the current anonymous player. mode is a PlayServExternalLoginMode:

ModeUse it whenWhat happens
PreserveCurrentPlayer (default)The player is signing in on the device they've been playing on.The provider is attached to the current player, who keeps their ID and progress.
RecoverProviderAccountThe player is restoring their account on a new device.The player who owns that provider account replaces the anonymous one.

The result's Status is Success, Conflict or Failed. A conflict means the provider account already belongs to another player: the current player is kept, and result.Conflict describes the other one, so you can offer to merge or to switch. A successful sign-in reconnects the game with the new session.

PlayServAuth.GetProvidersAsync() lists every provider with its Enabled and Available flags; offer the available ones on your sign-in screen.


Sign in through the browser

PlayServAuth.LoginBrowserAsync(provider, options) signs the player in on the provider's own web page, in WebGL, desktop builds and the Editor. WebGL opens a popup, desktop and the Editor the system browser. The SDK waits up to 5 minutes for the player to finish.

RuleWhy
In WebGL, call it straight from a click handler.Otherwise the browser blocks the popup and the result is BrowserPopupBlocked.
Run one browser sign-in at a time.A second one returns BrowserFlowInProgress.
Set AllowPlayerSwitch = true to let it switch players.If the provider account belongs to another player, the result is BrowserPlayerSwitchRequired unless you allow the switch.

Browser sign-in never links or merges accounts.


CallWhat it does
LinkIdentityAsync(proof)Attaches another provider to the current player. A player has one account per provider.
UnlinkIdentityAsync("google")Removes a provider. The last one can't be removed.
MergeIdentityAsync(conflict, choice, freshProof)Joins the current player and the one from a conflict into one. choice is PlayServMergeChoice.KeepCurrentPlayer or UseConflictingPlayer; freshProof is a new proof for the provider in conflict.

A merge moves sign-ins, not progress

The providers of the merged player move to the one that remains. The merged player's progress, purchases and records stay with it and are not copied.


The player's profile

PlayServAuth.GetCurrentPlayerProfileAsync() returns the signed-in player's own profile, loading it once; RefreshCurrentPlayerProfileAsync() loads it again.


Sign out

PlayServAuth.LogoutAsync() ends the session on the platform, clears it on the device, and signs in a new anonymous player. If the platform couldn't be told, the result's error says so; the device is signed out either way.


When sign-in fails

Failures come back in the result's Error. Only these throw: cancellation, a missing or invalid argument, and a call while the game is connecting or reconnecting.

ErrorWhenWhat to do
ProviderAlreadyLinkedThe provider account belongs to another player. result.Conflict is set.Offer to merge, or to switch to that player.
ProviderNotLinkedUnlinking a provider the player doesn't have.—
LastProviderUnlinkForbiddenUnlinking the player's last provider.Link another provider first.
MergeProviderConflictBoth players have an account of the same provider.Unlink one of them, then merge.
DeviceBannedThis device is banned.Tell the player; signing in again won't help.
ForbiddenThe player is banned or suspended: Error.BackendCode is player_banned or player_suspended.Tell the player.
InvalidCredential · UnauthorizedThe provider's token was rejected or has expired.Get a new token from the provider and try again.

Ban and suspension are final for this sign-in

A banned device or account can't sign in until an operator lifts it in Players. Don't loop on retries.

If the platform ends the session later, for example after a ban, PlayServAuth.SessionLost fires: see Connection & Session.

Using your own authentication server, through PlayServ Auth Token or PlayServ Webhook, is coming soon.


Next steps

Last updated on 19 Oct 2026