Federated Accounts
Have you ever played a game and forgotten if you signed in with Google or using your Gmail email? This is where Federated Accounts comes in handy.
With Federated Accounts, you can associate multiple login methods with a single account and wallet. If your user has signed in with a Guest login, you will definitely want to push them towards federating their account in order to have persistent credentials with which they can access their Sequence Embedded Wallet in subsequent sessions.
While a user is authenticated with the Sequence API, you can add an additional login method by using the appropriate federate account call:
UAuthenticator::FederateEmail
for email - make sure to bind to theAuthRequiresCode
delegate and complete the auth flow usingUAuthenticator::EmailLoginCode
UAuthenticator::FederateOIDCIdToken
orUAuthenticator::InitiateMobileFederateOIDC
for OIDCUAuthenticator::FederatePlayFabLogin
(existing account) orUAuthenticator::FederatePlayFabNewAccount
(new account) for PlayFab
EmailAlreadyInUse
By default, the Sequence API only allows one account per email. If a user attempts to login using a different method but the same email as before, they will receive an EmailAlreadyInUse
error.
For example: if the user created their account using Google Sign In and then attemps to sign in with Email + OTP using the same method, they will receive this error.
Before the sign in attempt, make sure to bind to the FederateSuccess
, FederateFailure
, and FederateOrForce
delegates. The FederateOrForce
delegate will be triggered in the case where the SDK receives the EmailAlreadyInUse
error from the API.
The FederateOrForce
delegate will include FFederationSupportData
which will contain the email used to sign in and a list of login methods associated with that email with the Sequence API.
With this information, you can present up to two options for the user to proceed:
- Prompt the user to login with one of the login methods included in the
FFederationSupportData
object. Once the user successfully logs in with one of the prompted login methods, the SDK will automatically federate their account using the cached login attempt that failed. e.g. if you previously logged in with Google, then tried to login with email and receive theEmailAlreadyInUse
error; after you login with Google again, your email will automatically be associated with your account. In subsequent sessions, you can now login with email + OTP to the same account. - Allow the user to force create a new account. This will give your user a separate account and wallet address. This can be done by calling
UAuthenticator::ForceOpenLastOpenSessionAttempt
. In general, we are hesitent to recommend this approach as having multiple accounts tied to the same email address may lead to a confusing end-user experience; however, we have enabled this behaviour should it be your preference.