Skip to main content

Platform Account Binding

Overview

Imagine that some mobile games allow players to play on both PC and Mobile. One potential problem would be:

How can we allow Google and Apple users to play that game on PC?

For PC games, so far only Garena accounts are allowed to play Garena games on PC. Hmm… what if we can combine Google / Apple and Garena accounts together to play both the PC and Mobile versions of that game.

That's it!!! That's the purpose of Platform Account Binding. It's for binding accounts of 2 different platforms together to utilize the advantages of each platform account.

Principle

Binding account B to account A on app C (Bind(A, B, C)) means creating a binding where A is the primary account and B is the secondary account on app C. After the binding happens:

  • If user login using account B, we will return access token that is generated from account A
  • If user login using account A, we will return access token that is generated from account A

For example, Google / Apple account is the primary account, and the Garena account is the secondary account. If the user login using Google / Apple, GOP will return an access token generated from Google / Apple account. If the user login using a Garena account, GOP will return an access token generated from the Google / Apple account that is its primary account, so that we can use that access token to play that game with the same credential as the mobile one.

Of course, one primary account can have multiple secondary accounts.


To bind account B to account A on app C (Bind(A, B, C)) successfully:

  • A has to be a primary account of app C.
  • B has to be a fresh account of app C.
  • platform_id(B) != platform_id(A)
  • There is no account D, such that platform_id(D) == platform_id(B) and account D is the secondary account of A in app C.
  • App C has APP_PLATFORM_BIND enabled.
  • platform_id(B) is in the list of secondary_app_platform_bind_list of App C.
  • platform_id(A) is in the list of primary_app_platform_bind_list of App C.

primary account of an app is

  • an account that has grant/role on that app.

secondary account of an app is:

  • not a primary account,
  • connected to a primary account, there is a record on the app account binding table.

fresh account of an app is:

  • not a primary account,
  • not connected to any primary account on this app.

Flow

Collaboration & Procedures

  1. Assume that the user is logged in, not using guest account
  2. Game calls Get Platform Account Binding Info via MSDK
  3. GOP returns the bound accounts and the available platforms that primary account can bind.
  4. Game use the above data to show info to user and allow user to login with secondary account based on the platforms returned.
  5. MSDK helps to launch app/web for authorization.
  6. Game client will receive the token for secondary account.
  7. Game client sends primary account's token and secondary account's token to game server
  8. Game server calls the bind API to GOP server, and returns the binding result to game client.

Sequence Diagram

Platform Account Binding Sequence

Get Binding Info

Platform Binding Status

After logging into a non-guest account, you can request the user's current platform account binding status to get both the bound accounts and available platforms to bind (which can be used to show platform options).

accountManager.getPlatformBindingInfo(new OnBindPlatformInfoListener() {

@Override
public void onSuccess(@NonNull List<BoundedAccount> boundedAccounts, @NonNull List<Integer> availablePlatforms) {

}

@Override
public void onFailure(@NonNull MSDKError error) {

}
});

Platform Binding Token

Get platform binding token by authenticating with a non-guest secondary platform account.

accountManager.getPlatformBindingToken(platformType, callback);

Handle Platform Account Binding Results

On Android only, after successfully binding a platform account through your game server, you need to notify MSDK to update its local state.

accountManager.onBindPlatformCompleted();