Authentication Service (Player Accounts)
using Coherence.Cloud;
using Coherence.Toolkit;
using System.Collections;
using UnityEngine;
using Result = Coherence.Runtime.Result;
public class LoginAsGuestExample : MonoBehaviour
{
public CoherenceBridge bridge;
private CloudService cloudService;
void Start()
{
cloudService = bridge.CloudService;
StartCoroutine(CheckRefreshLogin());
}
private IEnumerator CheckRefreshLogin()
{
IAuthClient authService = cloudService.GameServices.AuthService;
while (!cloudService.IsConnectedToCloud && authService.SessionTokenRefreshResult == null)
{
yield return null;
}
// If refresh failed, we have to login as a guest again
if (authService.SessionTokenRefreshResult == Result.InvalidCredentials)
{
var task = authService.LoginAsGuest();
while (!task.IsCompleted)
{
yield return null;
}
}
// At this point, we are ready to fully utilize the Cloud Service
}
}Was this helpful?

