I am creating a game for android. Each user needs to be authenticated.
Currently, when a new user launches the game, it requests an identification code from my server, and stores it to SharedPreferences. Next time user launches the game, it uses this stored identification code to authenticate. The problem is, when user clears data of this app, there's no way he can get his ID back, so he lost his progress forever.
Is there a way how to generate something like Identification code which is unique and always the same for one player using Firebase Play games auth method?
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
.requestServerAuthCode("MyCID")
.build();
mAuth = FirebaseAuth.getInstance();
super.onCreate(savedInstanceState);
final FirebaseAuth auth = FirebaseAuth.getInstance();
AuthCredential credential = PlayGamesAuthProvider.getCredential("MyCID");
auth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
currentUser = auth.getCurrentUser();
} else {
Toast.makeText(MainActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
if (currentUser == null) {
cu = "NO UID";
} else {
cu = currentUser.getUid();
}
I tried this code (Where is MyCID: I used the CID from the image below), but no Google Play Games pop-up is shown, I get Authentication Failed toast and cu is set to "NO UID".

Can someone explain how does this work please?
EDIT
Thanks to @crysxd , My app now shows the green google play games popup. But instead of expected "Select an account" popup, as I see in other games which uses google games sign in, I get an error, which says "com.google.android.gms.common.api.ApiException: 4:".
Is there a function which I need to run to show this dialog? Am I missing something or just I have incorrectly configured the game in google play console?
My current code: link