Unreal Engine

The Portal Gaming SDK for Unreal Engine facilitates the integration of your game with Portal Identity.

Compatibility and Support

Supported Platforms

  • Windows (64-bit).
  • macOS (minimum version 12.5).
  • Android (minimum version 5.1).
  • iOS (minimum version 15.2).

Supported Unreal Engine Versions

  • Unreal Engine 5.2.
  • Unreal Engine 5.0.
  • Unreal Engine 4.26.

Target Platform Compatibility Matrix

BUILD PLATFORMUNREAL ENGINE VERSIONWINDOWSMACOSIOSANDROID
Windows4.2,6
5.0.3
5.2.1??
macOS5.2.1

Setting Up OAuth 2.0 Native Client

Required Fields

  1. Application Type: OAuth 2.0 Native client.
  2. Client Name: Identifier for your application.
  3. Logout URLs:
    • For PKCE login on Android, iOS, and macOS: Set your app's logout deep link (e.g., mygame://logout).
    • Otherwise: Use your website, https://localhost:3000, or same as Redirect URLs.
  4. Redirect URLs:
    • For PKCE login on Android, iOS, and macOS: Set your app's deep link (e.g., mygame://callback).
    • Otherwise: Set to your website or https://localhost:3000.
    • Note: Windows clients don't support PKCE login, so Redirect URLs are unused.
  5. Web Origins URLs:
    • For Unreal Engine 5.0+: Leave blank..
    • For Unreal Engine 4.26 to 5.0: Add file:// to the list (required for BLUI browser).

Installation

  1. Install git-lfs from git-lfs.github.com
  2. Clone the portal-unreal-sdk repository.
  3. Copy the cloned repo into your project's Plugins folder (e.g., MyGame/Plugins/portal-unreal-sdk).
  4. Restart your project (Unreal Editor & JetBrains Rider IDE).

Additional Requirements for Unreal Engine 4

  • For UE 4.26 and 4.27, use BLUI plugin instead of WebBrowserWidget.
  • Download BLUI to your project's Plugins folder.
  • Download CEF Browser (BluBrowserCEF....7z) from BLUI-Unreal releases.
  • Place the Win folder from BluBrowserCEF...7z into your BLUI plugin Thirdparty/cef folder
  • Disable WebBrowserWidget plugin in portalgaming.uplugin file:
{
  "Plugins": [
    {
      "Name": "WebBrowserWidget",
      "Enabled": false
    }
  ]
}

SETUP

Blueprint

Explore sample widgets in All -> Plugins -> Portal Content in the Unreal Editor content browser. Enable Show Plugin Content in the content browser's Settings menu if needed.

C++

Refer to PortalIdentity.h for the C++ Identity API. Follow the same sequence as the Blueprint widget examples for Identity Login and Logout flows.

Quick Start

Authentication with Portal Identity

We use the Device Code Authorization flow for authentication and authorization.

To log a gamer into Identity:

  1. Call the Authenticate blueprint node.
  2. This opens the user's default browser for the auth flow.

Stored Credentials

The SDK stores credentials (access, ID, and refresh tokens) after successful authentication. Set useCachedSession to true in the Authorize blueprint node to use stored credentials for re-login.

Logging Out of Portal Identity

Use the Logout node with two options:

  1. Hard Logout: Clears sessions from both SDK and browser.
  2. Soft Logout: Clears only local session (set DoHardLogout to false).

PKCE Login for Android, iOS, and macOS

Use Authorization Code Flow with Proof Key for Code Exchange (PKCE) for a streamlined login process:

  1. Define a deep link scheme (e.g., mygame://callback for login, mygame://callback/logout for logout).
  2. Add deep links to your client's Redirect URLs and Logout URLs in Portal Hub.
  3. Set these deep links as redirect URI and logout redirect URI in Portal Identity Initialize.
  4. Call AuthenticatePKCE instead of Authenticate.

[IMAGE SCREENSHOT]

Platform-Specific Setup

Android Setup

  1. Create an Unreal Plugin Language XML file (e.g., Source/MyGame/MyGame_UPL_Android.xml).
  2. Add the following code to the XML file:
    <?xml version="1.0" encoding="utf-8"?>
    <root xmlns:android="http://schemas.android.com/apk/res/android">
        <androidManifestUpdates>
            <addElements tag="application">
                <activity
                        android:name="com.portalgaming.unreal.RedirectActivity"
                        android:exported="true" >
                    <intent-filter android:autoVerify="true">
                        <action android:name="android.intent.action.VIEW" />
                        <category android:name="android.intent.category.DEFAULT" />
                        <category android:name="android.intent.category.BROWSABLE" />
                        <data android:host="callback" android:scheme="mygame" />
                        <data android:host="logout" android:scheme="mygame" />
                    </intent-filter>
                </activity>
            </addElements>
        </androidManifestUpdates>
    </root>
    
  3. Modify your game's build file (e.g., Source/MyGame/MyGame.Build.cs):
    if (Target.Platform == UnrealTargetPlatform.Android)
    {
      string MyPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
      AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(MyPath, "MyGame_UPL_Android.xml"));
    }
    

iOS Setup

  1. In Unreal Editor, go to Project Settings -> iOS -> Extra PList Dat.

  2. Add the following to the Additional Plist Data field:

    <key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>mygame</string></array></dict></array>
    
    
    
    

macOS Setup

  1. Open the engine's Info.plist file (e.g., Engine/Source/Runtime/Launch/Resources/Mac/Info.plist)
  2. Add the following inside the root <dict>...</dict>:

Supported Functionality

METHODDESCRIPTION
InitializeIdentityInitializes Portal Identity
AuthenticateAuthenticates using Device Code Authorization
AuthenticatePKCE(Android, iOS, macOS only) Authenticates using PKCE
HasCredentialsSavedChecks for stored credentials from previous authentication
GetAccessTokenRetrieves the user's access token
GetIdTokenRetrieves the user's ID token
LogoutLogs out the user and removes stored credentials
LogoutPKCELogs out the user (for use with PKCE login)
ExecuteTransactionCreates a blockchain transaction
RequestWalletSessionKeyCreates a session key for the logged-in use

What’s Next