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 PLATFORM | UNREAL ENGINE VERSION | WINDOWS | MACOS | IOS | ANDROID |
---|---|---|---|---|---|
Windows | 4.2,6 | ✅ | ❌ | ❌ | ❌ |
5.0.3 | ✅ | ❌ | ❌ | ✅ | |
5.2.1 | ✅ | ? | ? | ✅ | |
macOS | 5.2.1 | ✅ | ✅ | ✅ | ✅ |
Setting Up OAuth 2.0 Native Client
Required Fields
- Application Type: OAuth 2.0 Native client.
- Client Name: Identifier for your application.
- 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.
- For PKCE login on Android, iOS, and macOS: Set your app's logout deep link (e.g.,
- 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.
- For PKCE login on Android, iOS, and macOS: Set your app's deep link (e.g.,
- 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
- Install git-lfs from git-lfs.github.com
- Clone the portal-unreal-sdk repository.
- Copy the cloned repo into your project's
Plugins
folder (e.g.,MyGame/Plugins/portal-unreal-sdk
). - 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 pluginThirdparty/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:
- Call the Authenticate blueprint node.
- 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:
- Hard Logout: Clears sessions from both SDK and browser.
- Soft Logout: Clears only local session (set
DoHardLogout
tofalse
).
PKCE Login for Android, iOS, and macOS
Use Authorization Code Flow with Proof Key for Code Exchange (PKCE) for a streamlined login process:
- Define a deep link scheme (e.g.,
mygame://callback
for login,mygame://callback/logout
for logout). - Add deep links to your client's Redirect URLs and Logout URLs in Portal Hub.
- Set these deep links as redirect URI and logout redirect URI in Portal Identity Initialize.
- Call
AuthenticatePKCE
instead ofAuthenticate
.
[IMAGE SCREENSHOT]
Platform-Specific Setup
Android Setup
- Create an Unreal Plugin Language XML file (e.g.,
Source/MyGame/MyGame_UPL_Android.xml
). - 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>
- 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
-
In Unreal Editor, go to Project Settings -> iOS -> Extra PList Dat.
-
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
- Open the engine's
Info.plist
file (e.g.,Engine/Source/Runtime/Launch/Resources/Mac/Info.plist
) - Add the following inside the root
<dict>...</dict>
:
Supported Functionality
METHOD | DESCRIPTION |
---|---|
InitializeIdentity | Initializes Portal Identity |
Authenticate | Authenticates using Device Code Authorization |
AuthenticatePKCE | (Android, iOS, macOS only) Authenticates using PKCE |
HasCredentialsSaved | Checks for stored credentials from previous authentication |
GetAccessToken | Retrieves the user's access token |
GetIdToken | Retrieves the user's ID token |
Logout | Logs out the user and removes stored credentials |
LogoutPKCE | Logs out the user (for use with PKCE login) |
ExecuteTransaction | Creates a blockchain transaction |
RequestWalletSessionKey | Creates a session key for the logged-in use |
Updated 28 days ago