Management API Reference

Authentication

User Session Management

Understand how to onboard with the Openfort signer solution.

Here's a complete example of managing sessions in Unity:


_72
using UnityEngine;
_72
using Openfort.OpenfortSDK;
_72
using Openfort.OpenfortSDK.Model;
_72
_72
public class SessionManager : MonoBehaviour
_72
{
_72
private OpenfortSDK openfort;
_72
_72
private async void Start()
_72
{
_72
openfort = await OpenfortSDK.Init("YOUR_OPENFORT_PUBLISHABLE_KEY");
_72
}
_72
_72
// Get the current access token
_72
public async Task<string> GetAccessToken()
_72
{
_72
try
_72
{
_72
string accessToken = await openfort.GetAccessToken();
_72
return accessToken;
_72
}
_72
catch (Exception e)
_72
{
_72
Debug.LogError($"Error getting access token: {e.Message}");
_72
return null;
_72
}
_72
}
_72
_72
// Using the access token for API requests
_72
public async Task MakeAuthenticatedRequest(string endpoint)
_72
{
_72
try
_72
{
_72
string accessToken = await GetAccessToken();
_72
_72
// Example using UnityWebRequest
_72
using (UnityWebRequest request = UnityWebRequest.Get(endpoint))
_72
{
_72
request.SetRequestHeader("Authorization", $"Bearer {accessToken}");
_72
await request.SendWebRequest();
_72
_72
if (request.result == UnityWebRequest.Result.Success)
_72
{
_72
string response = request.downloadHandler.text;
_72
// Handle response
_72
}
_72
}
_72
}
_72
catch (Exception e)
_72
{
_72
Debug.LogError($"API request failed: {e.Message}");
_72
}
_72
}
_72
_72
// Logout functionality
_72
public async Task LogoutUser()
_72
{
_72
try
_72
{
_72
await openfort.Logout();
_72
Debug.Log("User logged out successfully");
_72
_72
// Additional cleanup if needed
_72
// For example, return to login screen
_72
SceneManager.LoadScene("LoginScene");
_72
}
_72
catch (Exception e)
_72
{
_72
Debug.LogError($"Logout error: {e.Message}");
_72
}
_72
}
_72
}