Transition Player from Guest to Provider

In this how-to, we'll explain how to transition a player from a guest account to another provider.

A common flow in games is to get the player started playing as quickly as possible, and then later transition them to a more permanent authentication type, which also allows them to easily authenticate on other devices, We achieve this by starting them out with a guest account, which requires no input from the player, and then later nudging them to link their account with a different provider, like Apple or Google.

Prerequisites

Before we begin, ensure you have the following:

Transitioning a Player

To start transitioning the player from guest to another provider, we first need to authenticate the player with the new provider. This will give us the necessary token to connect the accounts.

In this example we'll use Apple sign in, but you can exchange this with another provider.

For more in depth information on how to authenticate with different providers, read our documentation on Authentication

Note that we don't start actually start a LootLocker game session using the new provider, we only do the local authentication with Apple to get the required token.

// The token retrieved from authenticating with Apple in the game client
string token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.0.xxxxx.xxxxxxxx-xxxxxxxxxxxxx";
LootLockerSDKManager.ConnectAppleAccount(token, (response) =>
{
    if(!response.success)
    {
        Debug.Log("Error connecting Apple");
        return;
    }

    Debug.Log("Successfully connected Apple");
});

After connecting the account, we can then disconnect the guest account. If we do not do this, the player will still be able to log in as a guest, which might not be what we want.

// The following providers are supported:
// LootLocker.LootLockerEnums.LootLockerAccountProvider.guest;
// LootLocker.LootLockerEnums.LootLockerAccountProvider.google;
// LootLocker.LootLockerEnums.LootLockerAccountProvider.apple;

var account = LootLocker.LootLockerEnums.LootLockerAccountProvider.guest;

LootLockerSDKManager.DisconnectAccount(account, (response) =>
{
    if(!response.success)
    {
        Debug.Log("Could not disconnect account");
        return;
    }

    Debug.Log("Successfully disconnected account");
});

You can also read our dedicated how-to for disconnecting an account here

Conclusion

By following this how-to guide, you should now have a better understanding of how to transition a player from a guest account to another provider.

To learn more about account linking, you can read our documentation on connecting multiple providers to a player here

Last updated