Third-party authentication
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'
, 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:
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.auth.authenticateWithThirdPartyProvider(request);
Debug.Log("Third-party authentication successful");
// Handle successful authentication
HandleAuthenticationSuccess(response);
}
catch (Exception e)
{
Debug.LogError(quot;Authentication error: {e.Message}");
}
}
private void HandleAuthenticationSuccess(PlayerResponse response)
{
// response.id contains the player ID
// response.linkedAccounts contains the linked provider accounts
Debug.Log(quot;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
Firebase Auth w/ Unity Android
An integration with Google Play Games using Firebase Auth as a third party auth provider.