Use Remote Login In-Game

Remote login makes it easy to start LootLocker sessions on devices where it's hard to enter their credentials, like on console. It also enables games to easily implement 1st party provider authentication without having to spend a long time manually implementing it into their game client.

Pre-requisites

The Remote Login Flow

The remote login flow consists of the following steps:

  • Initiate the remote login process, which will return a URL and QR code the player can use to log in

  • The player visits the URL and logs in using their preffered identity provider

  • Game client polls the server to check if the player has logged in yet

  • Once the player has logged in, the poll will return a success response with a LootLocker session and a refresh token

  • The next time the player opens the game, the refresh token can be used to start a new session without the player having to go through the full flow again

Starting a Remote Session

As this function requires three separate callbacks, it is easier to manage them as following:

public void RemoteLease()
{
    LootLockerSDKManager.StartRemoteSession(leaseAction, pollingAction, onComplete);
}

Action<LootLockerLeaseRemoteSessionResponse> leaseAction = (info) =>
{
    if (!info.success)
    {
        Debug.Log("Couldnt start Remote leasing");
        return;
    }
};
Action<LootLockerRemoteSessionStatusPollingResponse> pollingAction = (polling) =>
{
    if(!polling.success)
    {
        Debug.Log("Couldnt poll Remote leasing");
        return;
    }
};
Action<LootLockerStartRemoteSessionResponse> onComplete = (onComplete) =>
{
    if (!onComplete.success)
    {
        Debug.Log("Couldnt start Remote leasing");
        return;
    }
};

Cancel the remote login process

If we for some reason want to cancel the process mid way, this is how we can do it.

LootLockerSDKManager.StartRemoteSession returns a Guid which we can later use to cancel the remote session start process.

public void RemoteLease()
{
    var leasedGuid =  LootLockerSDKManager.StartRemoteSession(leaseAction, pollingAction, onComplete);
    LootLockerSDKManager.CancelRemoteSessionProcess(leasedGuid);
}

Use the Refresh Token to Start a Session

In the response while creating our remote session we get a refresh token back. This token can be used to start a new session without the player having to go through the full flow again.

LootLockerSDKManager.RefreshRemoteSession((onComplete) =>
{
    if(!onComplete.success)
    {
        Debug.Log("Couldnt refresh remote session!");
        return;
    }
});

With manually stored refresh token:

string refreshToken = "";
LootLockerSDKManager.RefreshRemoteSession(refreshToken, (onComplete) =>
{
    if(!onComplete.success)
    {
        Debug.Log("Couldnt refresh remote session!");
        return;
    }
});

Conclusion

In this how-to we've shown how to start and manage remote sessions from your game. If you want to learn more about UPA you can read about Connected Accounts or the general Unified Player Account page.

Last updated