User Authentication
Log players in to coherence Cloud
The User API enables the creation and management of user accounts for players that uniquely identify them across multiple devices.
The API offers many ways to authenticate your players with coherence Cloud and enabling them to make use of its services:
CoherenceBridge
CoherenceBridge's Inspector contains a coherence Cloud section that can be used to configure if and how the bridge should connect to coherence Cloud.
When a CoherenceBridge has been connected with a User, and the User has joined a lobby, the bridge will automatically join a play session started by the lobby's owner.
Auto Login As Guest
The quickest way to log a player in to coherence Cloud is to set User to Auto Login As Guest in a CoherenceBridge using the Inspector.

This will result in the player getting logged in to coherence Cloud as a guest automatically when the CoherenceBridge is loaded. The player will remain logged in until the CoherenceBridge is destroyed.
Guest ids are stored locally on the device, so it is important to know that uninstalling the game will also wipe out the data for the guest account, and players will no longer be able to access them even if they install the game again.
Main User
Setting User to Main User causes the CoherenceBridge to connect to coherence Cloud as the Main User.
When you log in to coherence Cloud using the User API, using any authentication method you want, it will result in a Main User being created. Once the user has successfully logged in, the CoherenceBridge will automatically connect to coherence Cloud as this user.
None
If User is set to None, then the CoherenceBridge will not connect to coherence Cloud automatically.
You can also connect a bridge with a User manually by assigning the User's Services to the the bridge's CloudService property:
User
You can use the User API to log in to coherence Cloud manually.
Login As Guest
You can use User.LoginAsGuest to log in to coherence Cloud using a guest account that is automatically generated for you.
Guest ids are stored locally on the device, so it is important to know that uninstalling the game will also wipe out the data for the guest account, and players will no longer be able to access them even if they install the game again.
Login With Password
You can use User.LoginWithPassword to log in to coherence Cloud using a username and password.
An autoSignup value of true can be passed to the method to automatically create a new coherence Cloud account with the provided username and password, if one does not exist already. The default value of autoSignup is false.
Login With Session Token
You can use User.LoginWithSessionToken to log in to coherence Cloud using a session token acquired from a previously login operation.
This can be useful to avoid users from having to re-enter their username and password every time they want to log in.
Session tokens will expire after a certain period of time after the last login operation.
Login With Steam
You can use User.LoginWithSteam to log in to coherence Cloud using a Steam account.
To do so, you have to provide at least an authentication ticket for the Steam User that you want to log in as. This can be acquired using SteamUser.GetAuthTicketForWebApi.
If you passed an identity string to the SteamUser.GetAuthTicketForWebApi method, you should also pass that same identity to the User.LoginWithSteam method.
Login With Epic Games
You can use User.LoginWithEpicGames to log in to coherence Cloud using an Epic Games account.
Login With PlayStation
You can use User.LoginWithPlayStation to log in to coherence Cloud using a PlayStation Network account.
Login With Xbox
You can use User.LoginWithXbox to log in to coherence Cloud using an Xbox account.
Login With Nintendo
You can use User.LoginWithNintendo to log in to coherence Cloud using a Nintendo Services account.
Login With JWT
You can use User.LoginWithJwt to log in to coherence Cloud using a custom JSON Web Token.
Login With Recovery Code
You can use User.LoginWithRecoveryCode to log in to coherence Cloud using a recovery code acquired from another device using User.GetRecoveryCode.
Linking
If you want to add multiple authentication methods to the same User Account, you can do so by first logging in using any of of the authentication methods, and then linking the rest of the authentication methods using the Link methods on the User class.
The User class provides the following methods for linking authentication methods into an existing User Account:
LinkGuest
LinkSteam
LinkPlayStation
LinkXbox
LinkNintendo
LinkJwt
Unlinking
Each of the Link methods listed above also have a corresponding Unlink method in the User class that can be used to remove an authentication method from the User Account.
If an authentication method is already linked with one User Account, and you try to link it with another one, the operation will fail by default. If however you pass a force value of true to a Link method, then the authentication method will automatically be unlinked from any existing User Accounts it's associated with.
Warning: If an authentication method is unlinked from an User Account, and the User Account has no other authentication methods set up, then access to that User Account will be lost.
Account Information
Username and Password
You can change the username and (optionally) password of a User Account using SetUsername.
If no password is provided, then the option to login with password will not be available. This might still be useful if the username is used for game purposes only and not as an authentication method.
You can remove the username and password from from a User Account using RemoveUsername.
If the User Account has no other authentication methods set up besides the username and password, then RemoveUsername will fail by default. If however you pass a force value of true to the method, then the username and password will be removed regardless.
Warning: Access to a User Account will be lost if the last authentication method is removed from it.
Display Name and Image
You can change the display name and image of a Use Account using SetDisplayInformation.
You can remove the display name and image from a User Account using RemoveDisplayInformation.
Email
You can assign an email address to a Use Account using SetEmail.
You can remove an email address from a User Account using RemoveEmail.
Last updated
Was this helpful?