Last active
January 7, 2020 03:28
-
-
Save LukmanaAfif/dc0d0b7dbcfc8b0ffdbbee12ea0cf2cb to your computer and use it in GitHub Desktop.
Login with Launcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const string AUTHORIZATION_CODE_ENVIRONMENT_VARIABLE = "JUSTICE_AUTHORIZATION_CODE"; | |
//Attempts to login with launcher | |
public void LoginWithLauncher() | |
{ | |
// Check if auth code is available from launcher | |
string authCode = Environment.GetEnvironmentVariable(AUTHORIZATION_CODE_ENVIRONMENT_VARIABLE); | |
if (authCode != null) | |
{ | |
abUser.LoginWithLauncher(OnLogin); | |
// Toogle loading animation | |
uiHandler.FadeLoading(); | |
} | |
else | |
{ | |
Debug.Log("LoginWithLauncher authCode is null"); | |
} | |
} | |
//Handles User Login, on Success it will get the User's account details | |
private void OnLogin(Result result) | |
{ | |
if (result.IsError) | |
{ | |
uiHandler.FadeLoading(); | |
Debug.Log("Login failed:" + result.Error.Message); | |
Debug.Log("Login Response Code: " + result.Error.Code); | |
//Show Error Message | |
} | |
else | |
{ | |
Debug.Log("Login successful. Getting User Data"); | |
//Show Login Successful | |
//Show "Getting User Details" | |
GetUserDetails(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment