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 implement authentication, we recommend using our LoginPanel
prefab. Locate this prefab under SequenceExamples > Prefabs
and drag it under a Canvas in your scene.
We recommend having the Canvas Scaler
component attached to your Canvas
use the "Scale with Screen Size" UI Scale Mode. This will make it so that the LoginPanel (and any other UI elements under this Canvas) are scaled automatically when switching between build targets.
Note: The LoginPanel
is hidden by default. You can open it with the Open
method and no arguments. To help with this, the LoginPanel
GameObject is not disabled, so feel free to use GetComponentInChildren, FindObjectOfType, or similar to obtain a reference to the LoginPanel
MonoBehaviour.
This will provide you easy access to two authentication methods:
The SDK also provides support for:
Retrieving the SequenceWallet
Once you've obtained credentials from one of the supported authentication methods (please see their respective documentation), you'll want to catch a reference to your newly created SequenceWallet
.
Please subscribe to the SequenceWallet.OnWalletCreated
event. This can be done with the following code snippet:
SequenceWallet.OnWalletCreated += OnWalletCreatedHandler;
public void OnWalletCreatedHandler(SequenceWallet wallet) {
// Do something
}
where OnWalletCreatedHandler
is a function accepting a SequenceWallet
as it's only parameter. If you're unfamiliar with working with events in Unity, check out this great Reddit post!
Error Handling
In order to catch errors during the login process, please make sure to subscribe to the OnLoginFailed
event.
SequenceLogin login = SequenceLogin.GetInstance();
login.OnLoginFailed += OnLoginFailedHandler;
public void OnLoginFailedHandler(string message, LoginMethod method, string email, List<LoginMethod> loginMethods = default)
{
Debug.LogError(quot;Error logging in: {message} with login method {method} and email {email}");
}