Skip to main content

Setup

Registering your game

Before using Passport, you must register your game as an OAuth 2.0 Native client in the Immutable Hub.

Authentication methods

There are two methods to authenticate and authorise players into Passport:

  1. Device Code Authorisation Device Code Authorisation is available for all supported platforms. This method opens the player's default browser and guides them through the authentication flow.

  2. Authorisation Code Flow with Proof Key for Code Exchange (PKCE) PKCE is available for Android, iOS, macOS and WebGL. This method simplifies the process by opening a pop-up window on macOS or an in-app browser on mobile devices, guiding users through the authentication flow. Once authenticated, players are automatically redirected back to the game, eliminating the need for manual switching.

Recommendation: For an optimal gaming experience on Android, iOS, macOS or WebGL, it is recommended to use the PKCE flow.

Configuration in Immutable Hub

How you configure your game in the Immutable Hub will depend on the authentication method you choose to log users into Passport.

Here's how you can configure the necessary fields when creating a client:

PropertyDescription
Application TypeYou must register your game as a Native client.
Application NameThe name you wish to use to identify your game.
Redirect URLsThis field is not used, but it is required. You can set it to your website or http://localhost:3000.
Logout URLsThe URL where the browser will redirect after logout is complete.
Web Origins URLsThe Unity SDK does not utilise this field. You can leave it blank.

Initialise Passport

Create a script with the following code and bind it to an object:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Immutable.Passport;

public class InitPassport : MonoBehaviour
{
private Passport passport;

async void Start()
{
// Replace with your actual Passport Client ID
string clientId = "YOUR_IMMUTABLE_CLIENT_ID";

// Set the environment to SANDBOX for testing or PRODUCTION for production
string environment = Immutable.Passport.Model.Environment.SANDBOX;

// Initialise Passport
passport = await Passport.Init(clientId, environment, logoutRedirectUri: "https://www.example.com");
}
}

Once initialised, you can access the Passport instance from anywhere in your project via Passport.Instance.