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:

  1. ECROSSxLoginProvider::All — Shows the provider selection sheet.
  2. ECROSSxLoginProvider::Google — Starts Google sign-in without the sheet.
  3. ECROSSxLoginProvider::Apple — Starts Apple sign-in without the sheet.

Session lifecycle

InitializeSdk()

Attempts to restore a stored session when the app starts.

FCROSSxAuthResult Restored = Sdk->InitializeSdk(); // bSuccess = false if restore fails

IsLoggedIn()

Checks whether a local access token exists and is not expired (no network refresh).

bool bLoggedIn = Sdk->IsLoggedIn();

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 on bMigrateAutomatically, or returns an error result with MigrationRequired error 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 broadcasts OnSessionExpired

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

  1. App start: Configure(Config) then InitializeSdk()
  2. Enable confirmation UI: EnableSignConfirmation(AppName)
  3. Before protected action: EnsureLoggedInAndRefresh()
  4. User sign-in: SignIn() / SignInWithCreateAsync() (optionally specify provider)
  5. User sign-out: SignOut()

© 2025 NEXUS Co., Ltd. All Rights Reserved.