Authentication
Unreal Authentication
OAuth sign-in and session handling for the Unreal SDK.
Sign-in providers
Choose the provider at runtime with SignIn(...) / SignInWithCreateAsync(...).
// Synchronous
FCROSSxAuthResult AuthAll = Sdk->SignIn(ECROSSxLoginProvider::All);
FCROSSxAuthResult AuthGoogle = Sdk->SignIn(ECROSSxLoginProvider::Google);
FCROSSxAuthResult AuthApple = Sdk->SignIn(ECROSSxLoginProvider::Apple);
// Asynchronous
Sdk->SignInAsync(ECROSSxLoginProvider::Google,
FCROSSxAuthResultDelegate::CreateLambda([](const FCROSSxAuthResult& R) { /* ... */ })
);Behavior:
ECROSSxLoginProvider::All— Shows the provider selection sheet.ECROSSxLoginProvider::Google— Starts Google sign-in without the sheet.ECROSSxLoginProvider::Apple— Starts Apple sign-in without the sheet.
Session lifecycle
InitializeSdk()
InitializeSdk()Attempts to restore a stored session when the app starts.
FCROSSxAuthResult Restored = Sdk->InitializeSdk(); // bSuccess = false if restore failsIsLoggedIn()
IsLoggedIn()Checks whether a local access token exists and is not expired (no network refresh).
bool bLoggedIn = Sdk->IsLoggedIn();EnsureLoggedInAndRefresh()
EnsureLoggedInAndRefresh()Ensures the current session is usable (includes restore/refresh attempts).
bool bOk = Sdk->EnsureLoggedInAndRefresh();Sign-in and sign-out
FCROSSxAuthResult Auth = Sdk->SignIn(ECROSSxLoginProvider::Google);
// Sign in + wallet creation in one call
Sdk->SignInWithCreateAsync(ECROSSxLoginProvider::Google,
FCROSSxAuthResultDelegate::CreateLambda([](const FCROSSxAuthResult& R) { /* ... */ })
);
// Re-authenticate after session expiry
Sdk->SignInAgainAsync(
FCROSSxAuthResultDelegate::CreateLambda([](const FCROSSxAuthResult& R) { /* ... */ })
);
Sdk->SignOut();
FCROSSxRefreshTokenResult TokenResult = Sdk->RefreshToken();After sign-in
Use SignIn() if you only need authentication; use SignInWithCreateAsync() if you need a wallet immediately.
When aligning the wallet via SignInWithCreateAsync() or later CreateWalletWithMigrateAsync(), the SDK checks wallet state and branches:
exists— Reuses the existing wallet. If no wallet password is stored, the SDK prompts once and saves it.migration_required— Either runs migration depending onbMigrateAutomatically, or returns an error result withMigrationRequirederror type.not_found— Creates a new wallet and prompts for a password.
Sdk->CreateWalletWithMigrateAsync(true,
FCROSSxCreateWalletDelegate::CreateLambda([](const FCROSSxCreateWalletResult& R)
{
UE_LOG(LogTemp, Log, TEXT("Address: %s"), *R.Address);
})
);
// Manual migration control
Sdk->CreateWalletWithMigrateAsync(false,
FCROSSxCreateWalletDelegate::CreateLambda([](const FCROSSxCreateWalletResult& R)
{
if (!R.bSuccess)
{
// Handle MigrationRequired error
}
})
);Session expiry handling
When access and refresh tokens both expire, the SDK shows a session expired modal with two options:
- Sign in again — calls
SignInAgainAsync()to re-authenticate - Sign out — calls
SignOut()and broadcastsOnSessionExpired
This flow is handled automatically within WithAutoRefresh for all authenticated API calls.
Events
// Subscribe to events
Sdk->OnSignInComplete.AddDynamic(this, &AMyActor::OnSignIn);
Sdk->OnSignOutComplete.AddDynamic(this, &AMyActor::OnSignOut);
Sdk->OnSessionExpired.AddDynamic(this, &AMyActor::OnExpired);Recommended app flow
- App start:
Configure(Config)thenInitializeSdk() - Enable confirmation UI:
EnableSignConfirmation(AppName) - Before protected action:
EnsureLoggedInAndRefresh() - User sign-in:
SignIn()/SignInWithCreateAsync()(optionally specify provider) - User sign-out:
SignOut()
Updated about 20 hours ago