Guest Mode
Learn how to implement guest authentication in your application
User data and embedded wallets from guest sessions cannot be merged into an existing user account — guest accounts can only be upgraded into a new user account. If a guest user wants to log in with an existing account, you must delete the guest user session first.
Use the OnSignUpGuest
method from the Openfort SDK to create a guest account:
_22 public async void OnSignUpGuest()_22 {_22 loadingPanel.SetActive(true);_22 registerButton.interactable = false;_22 statusTextLabel.text = $"Logging In As Guest ...";_22 try_22 {_22 AuthResponse authResponse = await openfort.SignUpGuest();_22 accessToken = authResponse.Token;_22 await SetAutomaticRecoveryMethod();_22 loginPanel.SetActive(false);_22 statusTextLabel.text = $"Logged In As Guest";_22 loggedinPanel.SetActive(true);_22 }_22 catch (System.Exception)_22 {_22 loginPanel.SetActive(false);_22 registerPanel.SetActive(true);_22 }_22 signinButton.interactable = true;_22 loadingPanel.SetActive(false);_22 }
Upon successful registration, you'll receive a response containing the player information and authentication tokens:
_10{_10 "player": {_10 "id": "pla_...",_10 "object": "player",_10 "createdAt": 1234567890,_10 "linkedAccounts": []_10 },_10 "token": "eyJhbG...",_10 "refreshToken": "eyJhbG..."_10}
Upgrade a guest user to a logged-in user#
Simply call link method to enable the guest user to upgrade their account to a logged-in account using any authentication method of their choice.