Skip to main content

Authentication Reference

This document is a reference to the Authentication module of the Myria Game SDK.

info

The Myria Game SDK and its functionality is currently being internally tested by Myria game projects. If you're interested in learning more, then please contact our team.

Classes

AuthenticationUserData

Data structure returned by the GetAuthenticationData method.

public class AuthenticationUserData
{
public string user_id { get; set; }
public string last_name { get; set; }
public string first_name { get; set; }
public string username { get; set; }
public string email { get; set; }
public DateTime updated_on { get; set; }
public List<string> user_roles { get; set; }
public DateTime last_activity { get; set; }
public DateTime created_on { get; set; }
public string access_token { get; set; }
public string session_id { get; set; }
public string refresh_token { get; set; }
public DateTime access_token_expiry { get; set; }
public DateTime refresh_token_expiry { get; set; }

public void FillAuthenticationData(UserData userData)
{
//
}
}

Events

OnAccessTokenExpire

An event that triggers when the token is expired.

Example

public override void Init()
{
base.Init();
MyriaSDK.Instance.AuthenticationService.OnAccessTokenExpire.AddListener(OnAccessTokenExpires);
}

private void OnDestroy()
{
MyriaSDK.Instance.AuthenticationService.OnAccessTokenExpire.RemoveListener(OnAccessTokenExpires);
}

Methods

GetAuthenticationData

Gets the authentication data of the player.

Declaration

UniTask<Result<AuthenticationUserData>> GetAuthenticationData()

Returns

Returns a Result<AuthenticationUserData> object with login details.

Example

private async void GetToken()
{
var accessToken = await MyriaSDK.Instance.AuthenticationService.GetAuthenticationData();
Debug.Log($"ACCESS_TOKEN: {accessToken.Response.access_token}");
}

IsPlayerLoggedIn

Checks the authentication status of the player.

Declaration

UniTask<bool> IsPlayerLoggedIn()

Returns

Returns a boolean value that defines if the player is logged in.

Example

private async void IsLoggedIn()
{
var isLoggedIn = await MyriaSDK.Instance.AuthenticationService.IsPlayerLoggedIn();
Debug.Log($"IsLoggedIn: {isLoggedIn}");
}

ValidateToken

Checks the validity of the player's access token.

Declaration

UniTask<bool> ValidateToken()

Returns

Returns a boolean value that defines if the player's access token is valid.

Example

private async void ValidateToken() => await MyriaSDK.Instance.AuthenticationService.ValidateToken();