Skip to main content

Auth Interface

This article outlines the typical functions supported by the Player Network authentication services and the instructions to use them.

Enable automatic login

Developers can implement auto-login by calling the AutoLogin method. This allows games to authenticate players using a valid authentication state stored in the local cache. The local authentication state is retrieved and validated against the backend server. If there is no locally cached authentication state, or if the server is unable to validate the authentication state, auto-login will fail. In such cases, developers will need to call Login to authenticate the player through their user input.

INTLAPI.AutoLogin();

Login with user input

Developers can call the Login method to open a third-party login page for players to manually enter their credentials and log in through the specific identity provider. The input parameters required for Login method include the identity provider, the permissions requested by the identity provider, and any additional information required by the identity provider.

For specific permissions and additional information required by each identity provider, refer to their integration tutorials for details.

The following sample code takes Facebook as an example.

INTLAPI.Login(INTLChannel.Facebook); 

Link player accounts

Games can associate unique identifiers (UIDs) from different identity providers with a single Player Network SDK OpenID. This feature enables players to link their accounts such as Facebook, Google, Twitter, and guest accounts, thereby allowing them to share their game progress across these accounts.

To link player accounts, players must first be successfully logged into the game. Developers then need to call the Bind method, which opens the login page of the third-party account. The input parameters for the Bind method include the channel definition of the identity provider the player wants to link to, the permissions requested by the identity provider, and any additional information required by the identity provider. For specific permissions and additional information required by each identity provider, refer to their integration tutorials for details.

If the login is successful, the identity provider server will return the UID for the Player Network to link to the OpenID, thus linking the account to the current login account. If the UID cannot be linked to the OpenID, the Player Network server will return an error code. This error code may indicate that the UID is already linked to an OpenID, or that the UID cannot be linked to the OpenID because only one UID from the same channel can be linked to a unique OpenID. For instance, this means that a single OpenID cannot be linked to two different Facebook UIDs.

If the current login channel is a guest account when the Bind method is called, the guest account can be linked to any identity provider accounts passed to the Bind method. On the other hand, if the active login channel is an identity provider account when the Bind method is called, the identity provider account can only be linked to other identity provider accounts passed to the Bind method, not to the guest account.

Image

The following sample code takes Facebook as an example.

INTLAPI.Bind(INTLChannel.Facebook);

Developers have the ability to unlink an identity provider account from the OpenID. After successful unlinking, players will no longer be able to log into the game using the unlinked account. The next time players attempt to log in using the unlinked account, a new OpenID will be generated.

To unlink a player account, developers need to call the Unbind method, providing the channel ID of the identity provider. Two optional parameters can also be included: the UID of the identity provider account and any additional data required by the identity provider.

The following sample code takes Facebook as an example.

INTLAPI.Unbind(4); //Unlink the Facebook channel

Log out a player

Developers can provide players with the option to log out of the game from their active login channel. This can be achieved by calling the Logout method without any input parameters, which will log the player out from their currently active login channel.

INTLAPI.Logout();

Transfer guest account

Player Network allows guest accounts to transfer from one device to another without losing any data using transfer codes. For instance, a player logged into the game with OpenID A on Device A sets a guest account password and generates a transfer code.

INTLAPI.GenerateTransferCode("password");

Then, on Device B, they enter this password and the transfer code. This logs them into the game on Device B, effectively transferring the account. Now, the guest account on Device B is associated with OpenID A, indicating a successful transfer.

INTLAPI.TransferAccount("transferCode","password");