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:
_13using UnityEngine;_13using Openfort.OpenfortSDK;_13using Openfort.OpenfortSDK.Model;_13_13public class OpenfortAuthManager : MonoBehaviour _13{_13 private OpenfortSDK openfort;_13 _13 private async void Start()_13 {_13 openfort = await OpenfortSDK.Init("YOUR_OPENFORT_PUBLISHABLE_KEY");_13 }_13}
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.
_33public class OpenfortAuthManager : MonoBehaviour _33{_33 // ... previous code ..._33_33 public async Task AuthenticateWithProvider(string token)_33 {_33 try _33 {_33 var request = new ThirdPartyProviderRequest(_33 ThirdPartyOAuthProvider.Firebase, // Or other provider_33 token,_33 TokenType.IdToken // Or TokenType.CustomToken_33 );_33 _33 var response = await openfort.AuthenticateWithThirdPartyProvider(request);_33 Debug.Log("Third-party authentication successful");_33 _33 // Handle successful authentication_33 HandleAuthenticationSuccess(response);_33 }_33 catch (Exception e)_33 {_33 Debug.LogError($"Authentication error: {e.Message}");_33 }_33 }_33_33 private void HandleAuthenticationSuccess(PlayerResponse response)_33 {_33 // response.id contains the player ID_33 // response.linkedAccounts contains the linked provider accounts_33 Debug.Log($"Authenticated player ID: {response.Id}");_33 }_33}
Authentication response#
Upon successful authentication, you'll receive a response containing:
_12{_12 "id": "pla_cc9ed2b7-c5f5-4c43-8dca-c4b104ba1762",_12 "object": "player",_12 "createdAt": 1710976453,_12 "linkedAccounts": [_12 {_12 "provider": "firebase",_12 "disabled": false,_12 "externalUserId": "2"_12 }_12 ]_12}