Authentication - Introduction
As an Embedded Wallet SDK, authentication is extremely important. Authentication works by establishing a session signing wallet through association with user credentials. For more on how our Embedded Wallet works, please see Embedded Wallet docs.
To get up and running quickly, we recommend using our default UI. This UI will already have the authentication integrated; so, provided you've correctly installed and setup the plugin, the authentication should work automatically with the default UI.
This will give you access to authentication via:
- Email + OTP Sign In
- OIDC-based Social Sign In
- PlayFab Sign In
- Guest Sign In
Built-in UI Setup
You can use the [BP_CustomSpectatorPawn]
but since it and its parent class reside within the realm of the plugin, during updates all modifications you make within the plugin would be lost. These serve primarily as a reference and starting point. We highly recommend you duplicate the BP_CustomSpectatorPawn
out of the plugin folder, then update its parent class to a C++ class of your own making that also resides outside the plugins content folder.
Some additional setup of the GameMode will need to be done prior to any UI showing up. The SequencePlugin comes bundled with an example GameMode [GM_Sequence]
stored within [Demonstration]
in the plugin content folder. Duplicate this GameMode and move it outside the plugin folder. Then open up [GM_Sequence]
and set the DefaultPawn to the Pawn Blueprint you've just made.
Lastly in Project Settings you'll need to set this GameMode as the default GameMode. Specifically in ProjectSettings -> Maps & Modes
Note: Unreal's web browser plugin uses the Chromium embedded browser. If your device does not support it, you can instead use Unreal's Launch URL
function.
Customizing the built-in UI
In the folder located at SequencePlugin Content/Core/Style you'll find a struct F_SequenceUIStyle
. In the default values section of this struct you'll be able to update the colours and images displayed throughout the UI. Currently we only read from Sequence_Style_Dark_Mode
Custom UI Integrations
To start you'll want to create a [UAuthenticator]
UObject like so [UAuthenticator * Auth = NewObject<UAuthenticator>()]
, this UObject manages the authentication side of Sequence.
In a C++ UObject with a series of pass through [UFUNCTIONS]
setup similarly to [SequenceBackendManager.h/.cpp]
. Each of these calls are implemented in [UAuthenticator]
you just need to pass through the data with YOUR UAuthenticator UObject
/*
Used to initiate mobile Social Signin
(No other calls need to be made to complete mobile SSO)
*/
void InitiateMobileSSO(const ESocialSigninType& Type)
/*
Optional Call,
Used to set a custom encryptor implementation for the Authentication Process
*/
void SetCustomEncryptor(UGenericNativeEncryptor * EncryptorIn);
/*
This call is for generating a login URL for Desktop based Social Signin
the received URL is fed into a WebBrowser to begin the login process
*/
FString GetLoginURL(const ESocialSigninType& Type);
/*
This is call is for undergoing social login once an ID_Token has been collected.
*/
void SocialLogin(const FString& IDTokenIn);
/*
This Call is made after you've collected the email address from the Users in the UI
The Delegate **[AuthRequiresCode]** will fire when a code is ready to be received
by the UAuthenticator
*/
void EmailLogin(const FString& EmailIn);
/*
This is call is made after the Delegate **[AuthRequiresCode]** is fired
The Code collected from the User in the GUI is sent in via this call
*/
void EmailCode(const FString& CodeIn);
/*
Optional call used to retrieve stored credentials on disk
*/
FStoredCredentials_BE GetStoredCredentials() const;
/*
Optional call used to check if the credentials on disk are valid or not
*/
bool StoredCredentialsValid();
Binding to the Delegates
Be sure to bind to the Delegates for [AuthSuccess], [AuthFailure], [AuthRequiresCode] prior to making any signin calls You can bind to these delegates like so:
this->authenticator->AuthRequiresCode.AddDynamic(this, &AYourClass::YourCallReadyToReceiveCode);
this->authenticator->AuthFailure.AddDynamic(this, &AYourClass::YourCallShowAuthFailureScreen);
In the case of [AuthSuccess] since a parameter is also passed we bind to it like this
FScriptDelegate del;
del.BindUFunction(this, "CallShowAuthSuccessScreen");
this->authenticator->AuthSuccess.Add(del);
Note: Replace the usage of the SequenceBackendManager.h/.cpp
with you're own when building a custom GUI, it is only used here as a reference in the event more context is needed with these instructions. Where [CallShowAuthSuccessScreen] is defined in SequenceBackendManager.h as an example like so:
UFUNCTION()
void CallShowAuthSuccessScreen(const FCredentials_BE& CredentialsIn);
And in SequenceBackendManager.cpp like so:
void ASequenceBackendManager::CallShowAuthSuccessScreen(const FCredentials_BE& CredentialsIn)
{
this->Credentials = CredentialsIn;
if (this->ShowAuthSuccessDelegate.IsBound())
this->ShowAuthSuccessDelegate.Broadcast(Credentials);
else
UE_LOG(LogTemp, Error, TEXT("**[Nothing bound to: ShowAuthSuccessDelegate]**"));
}