- Home /
Google play game service won't authenticate
I recently tried to implement Google Play Services into my project in order to make a leaderboard. The problem is that when I run the game, when it tries to authenticate the user, (Using Social.localUser. Authenticate) a green google play box pops up, it shows a loading animation which cuts off, and nothing else happens. Here are some things to note: I am publishing the game in the production section in google play console, (Meaning I don't have to list any tester emails) I have made a keystore, I have made sure to use the correct SHA1 for the OAuth 2.0 in the service, I have made sure in unity to do Window>Google Play Games>Setup>Android Setup, I have also made sure to use the Play Service Resolver in unity. There are a few more things that I probably forgot to list here too... Here is some of my code (C#):
public class PlayGamesController : MonoBehaviour {
public GameObject ErrTxt;
void Start() {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
if(SceneManager.GetActiveScene().buildIndex == 0) {
Authenticate();
}
if(SceneManager.GetActiveScene().buildIndex == 1) {
if(!Social.localUser.authenticated) {
ErrTxt.GetComponent<Text>().text = "Could not sign into Google Play";
}
}
}
void Authenticate() {
Social.localUser.Authenticate((bool success) => {
if(success) {
Debug.Log("Authenticated!");
SceneManager.LoadScene(1);
} else {
Debug.Log("Could not authenticate.");
SceneManager.LoadScene(1);
}
});
}
}
One more thing, when you switch scenes, do you need to re-authenticate? Do I have to keep the object that this script is attached to from being destroyed after each scene?
Answer by hypernaturalgames · Jun 03, 2019 at 06:35 PM
@apricotseed101 Your code seems OK to me. I'm using a code pretty much like yours, but I'm in an Open Beta phase.
The problem I'm actually having is that not all Google accounts can login. Login is working perfectly with some accounts and not with others. At first I though it was because I'm using and old tablet with Android 4.4 to test, but I've tried a new account in that same tablet and the Login is working fine, and when I try to login my old account, it fails.
That same old account can login in other games from the playstore, though ... so perhaps if I upload the game into Production, the problem may be solved. I'm not sure.
I've checked everything already, accounts listed for testing, SHA-1 certificate, forced service resolver, etc etc.