Authentication API
Learn how to work with authentication in SDK.
Methods
Check Availability of Authentication
To find out if authentication (internal, external) is available on the platform, you can use the method FREE:
- JavaScript
- Unity
gp.platform.hasIntegratedAuth; // boolean
GP_Platform.HasIntegratedAuth(); // bool
Check Availability of Authentication via Secret Code
To find out if authentication via secret code is available on the platform, you can use the method FREE:
- JavaScript
- Unity
gp.platform.isSecretCodeAuthAvailable; // boolean
GP_Platform.IsSecretCodeAuthAvailable(); // bool
Learn more about authentication via secret code.
Check Authentication Status
To determine if the player is authenticated through internal or external authentication system, you can use the method FREE:
- JavaScript
- Unity
gp.player.isLoggedIn; // boolean
GP_Player.IsLoggedIn(); // bool
Perform Login
To trigger the login window, you can use the method +0-1 Request:
- JavaScript
- Unity
gp.player.login();
GP_Player.Login();
Wait for the login event by subscribing to the event FREE:
- JavaScript
- Unity
gp.player.on('login', (success) => {});
// Event subscriptions
private void OnEnable()
{
GP_Player.OnLoginComplete += OnLoginComplete;
GP_Player.OnLoginError += OnLoginError;
}
// Event unsubscriptions
private void OnDisable()
{
GP_Player.OnLoginComplete -= OnLoginComplete;
GP_Player.OnLoginError -= OnLoginError;
}
// Event handling
private void OnLoginComplete()
{
Debug.Log("LoginComplete");
}
// Event handling
private void OnLoginError()
{
Debug.Log("LoginError");
}
After logging in, remember to update the interface and set new values in the game for variables that changed after login.
Logout from Account
To check if account logout is available on the platform, you can use the method FREE:
- JavaScript
- Unity
gp.platform.isLogoutAvailable; // boolean
GP_Platform.IsLogoutAvailable(); // bool
You can logout the player using the method +0-1 Request:
- JavaScript
- Unity
gp.player.logout();
GP_Player.Logout();
Wait for the logout event by subscribing to the event FREE:
- JavaScript
- Unity
gp.player.on('logout', (success) => {});
// Event subscriptions
private void OnEnable()
{
GP_Player.OnLogoutComplete += OnLogoutComplete;
GP_Player.OnLogoutError += OnLogoutError;
}
// Event unsubscriptions
private void OnDisable()
{
GP_Player.OnLogoutComplete -= OnLogoutComplete;
GP_Player.OnLogoutError -= OnLogoutError;
}
// Event handling
private void OnLogoutComplete()
{
Debug.Log("LogoutComplete");
}
// Event handling
private void OnLogoutError()
{
Debug.Log("LogoutError");
}
After logging out, remember to update the interface and set new values in the game for variables that changed after logout.
Get Player ID on the Platform
To retrieve the player's ID on the platform or in an external authentication system, you can use the method FREE:
- JavaScript
- Unity
gp.player.get('credentials'); // string
GP_Player.GetString("credentials"); // string
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram
: @gs_community.
For your suggestions e-mail
: [email protected]
We Wish you Success!