Getting Started With Connected Accounts

Author image
Johannes Fornaeus5 min read
Cover image

Here at LootLocker, our mission is to make cross-platform feel like one platform. With the release of Unified Player Accounts, we’re one step closer to this goal.

In short, Connected Accounts allows your players to upgrade and connect several first party platform accounts (like Steam, Apple, and PlayStation) into one single account to use across a game (or even multiple games). For example, players could start with a Guest account that doesn’t require any login information, attach their Google Account, log in with that on their iOS device and attach their Apple account. Then, regardless of which device they play on, their account information will always be synchronized.

As you can see, this feature can be immensely powerful. But with great power, comes great responsiblity... to implement it in your game correctly! If implemented poorly Connected Accounts can result in your player's data becoming inaccessible or completely lost, definitely resulting in player churn!

In this guide we will make sure you have all the tools necessary to use this powerful feature within your Unity game, all while avoiding any potholes along the way!

Alright, let's dive in.

Why Use Connected Accounts?

Connected Accounts is a great feature for games that want to:

  • Get players into the gameplay without logging in, but still provide the ability to secure their account once they're hooked
  • Connect multiple platforms together to unlock cross-platform features like cross-progression and cross saves
  • Let players create an account with your game after playing for a certain period of time

Connecting Accounts Together in Your Game

If you've played a mobile game before from any of the big publishers, you're probably already familar with this flow: you start playing the game without ever authenticating (logging in), and then after getting hooked you are encouraged to connect your Apple or Google account, or sign up with a game/publisher specific account. This is essentially Connected Accounts in action.

Translating that to the lanugage we use at LootLocker, you're starting the game with a Guest account (using Guest Login) and then being prompted to connect your Google or Apple account (Platform Login). This Unity guide will show you how to achieve this in a secure, simple and intuitive way for the player.

Let's start off simple by starting a Guest Session with the following code.

Alright, simple and easy. Now, let’s say that our players have played our game for some time, and we want them to connect their Google Login to make their account more secure (and to access their account from other devices). This is where Connected Accounts kicks in!

In our game, we need to call the Google sign-in API to get this user's id_token. We've written a separate guide on how to do this.

With the session token from Google obtained, we will now let LootLocker know that we want this Google Login to be connected to this player.

If everything is set up correctly, we will get a successful response back telling us it worked. It's as simple as that!

Removing the Old Guest Account

Now, this is all quite straight forward when you only have two identity providers and the player is essentially just upgrading the Guest Account to a more secure account (Platform Login).

For security reasons, we always recommend removing the Guest account from the player's profile so that you can only login again with your secure Google account! Otherwise another player could theoretically use the Guest account ID and pretend to be a different player. Here's how to remove the player's old Guest account.

Upping the Ante with Multiple Identity Providers

The real pitfalls of Connected Accounts come when you have your game on multiple platforms with multiple identity providers.

Say now that our user starts playing on an iOS device after they have started playing on their Android device using their Google Platform Login. Now they want to get the progress from their Android phone to their iPhone.

To do this we will let the player login with both Apple and Google on either their Android or iPhone by implementing both logins on both devices. The player would then have the possibility to connect their Apple account on their Android phone or vice versa.

Here's how that's done:

We have an enum that contains just two variables, Google and Apple. This is to specify which provider they have an active session with. We set the enum when we first authenticate the player. Then depending on which enum that is chosen, we show just one button for the other identity provider. This is so the user doesn't get confused. For example, say they logged in with Google first and then tried to connect Google again. Instead of risking it, we simply only show the provider which hasn't been used yet.

Note: As we are using two external identity providers, we do not have to remove any accounts like we did with the Guest account.

So that's it - now you know the basics of Unified Player Accounts and are ready to implement it in your own game. This feature can be hugely powerful in the growing world of multi-device gamers and cross-platform games where you want to make sure they can continue with their game regardless of where or when they play it.

As always, you can find all the documentation and other resources for this feature in the links below:

Stay up to date.

Join our newsletter and get these posts sent directly to your inbox.