Management API Reference

Authentication

Third-party authentication

Learn how to integrate with third-party auth provider.

Openfort's embedded signers are fully compatible with any authentication provider that supports JWT-based, stateless authentication. This guide will show you how to integrate third-party authentication providers in your Unity game.

Follow the guide on how to configure third party auth to learn more. The supported loginMethods are 'accelbyte', 'custom', 'firebase', 'supabase', 'lootlocker', 'playfab', 'telegramMiniApp' and 'oidc'.

Basic Setup#

First, create a manager class to handle Openfort authentication:

using UnityEngine;
using Openfort.OpenfortSDK;
using Openfort.OpenfortSDK.Model;

public class OpenfortAuthManager : MonoBehaviour
{
private OpenfortSDK openfort;

private async void Start()
{
openfort = await OpenfortSDK.Init("YOUR_OPENFORT_PUBLISHABLE_KEY");
}
}

Authenticate with third-party provider#

Here's how to authenticate using a third-party provider:

To make these instructions concrete, this guide uses Firebase as a sample third party auth provider that you can integrate alongside Openfort.

public class OpenfortAuthManager : MonoBehaviour
{
// ... previous code ...

public async Task AuthenticateWithProvider(string token)
{
try
{
var request = new ThirdPartyProviderRequest(
ThirdPartyOAuthProvider.Firebase, // Or other provider
token,
TokenType.IdToken // Or TokenType.CustomToken
);

var response = await openfort.AuthenticateWithThirdPartyProvider(request);
Debug.Log("Third-party authentication successful");

// Handle successful authentication
HandleAuthenticationSuccess(response);
}
catch (Exception e)
{
Debug.LogError($"Authentication error: {e.Message}");
}
}

private void HandleAuthenticationSuccess(PlayerResponse response)
{
// response.id contains the player ID
// response.linkedAccounts contains the linked provider accounts
Debug.Log($"Authenticated player ID: {response.Id}");
}
}

Authentication response#

Upon successful authentication, you'll receive a response containing:

{
"id": "pla_cc9ed2b7-c5f5-4c43-8dca-c4b104ba1762",
"object": "player",
"createdAt": 1710976453,
"linkedAccounts": [
{
"provider": "firebase",
"disabled": false,
"externalUserId": "2"
}
]
}

Example#