Hello there.
I’m currently trying to setup an android user login using the Play Games Services Plugin & Unity Authentication package but it keeps on failing. Below you can see the current code.
public void Login(UnityAction callbackSuccess, UnityAction callbackFailure)
{
PlayGamesPlatform.Instance.Authenticate(OnLogin);
}
void OnLogin(SignInStatus signInStatus)
{
if (signInStatus == SignInStatus.Success)
{
Dbg.Log(this, "[CloudSave] [Android Auth] Start ReqestServerSideAccess");
PlayGamesPlatform.Instance.RequestServerSideAccess(false, code =>
{
Dbg.Log(this, "[CloudSave] [Android Auth] Login with Google Play games successful. Authorization code: " + code);
_ = SignInWithGoogleAsync(code);
});
}
else
{
....
}
}
// https://docs.unity.com/authentication/PlatformSignInGooglePlayGames.html
async Task SignInWithGoogleAsync(string idToken)
{
if(AuthenticationService.Instance.IsSignedIn)
{
try
{
await AuthenticationService.Instance.LinkWithGoogleAsync(idToken);
Dbg.Log(this, "[CloudSave] [Android Auth] ╰(*°▽°*)╯╰(*°▽°*)╯╰(*°▽°*)╯ Link to account is successful.");
m_CallbackSuccess?.Invoke();
}
//Catch Stuff
} else
{
try
{
await AuthenticationService.Instance.SignInWithGoogleAsync(idToken);
Dbg.Log(this, "[CloudSave] [Android Auth] SignInWithGoogleAsync is successful.");
m_CallbackSuccess?.Invoke();
}
//...Catch stuff
}
}
The PGS Plugin itself seems to work fine. I see the UI and my User when I start the application. The PGS Authenticate method call also seems to work fine - it logs “Authentication Succeeded”.
Now the RequestServerSideAccess call returns
“Requesting Server Side Access Task Failed - Com.Google.Android.GMS.Common.API.APIException 10”
and the resulting authcode is empty. Therefore the LinkWithGoogleAsync or SignInWithGoogleAsync method calls are returning “no token provided” errors.
I also tried to get the User ID via var id = ((PlayGamesLocalUser)PlayGamesPlatform.Instance.localUser).id;
and var userID = PlayGamesPlatform.Instance.GetUserId();From there I get my userID A_XXXXXX… but it seems like this is not what the Authentication methods need. I get the following error msg:
I also tried Authentication.instance.Link/SignInWithGooglePlayGamesAsync - same error.
From my point of view I set everything up how it should be:
I installed the authentication 2.2.0 via the package manager.
I Installed the Play Games Services Plugin 0.11.01
I did set it up how the documentation told me. I added the Android Resources from the play console and I also provided a web app client id.
In the play console I configured the play games services and added/linked OAuth 2.0-Client-IDs via the Google Cloud platform. Both SHA1 keys (Signing & Upload) I get from the play console app integrity page are linked where they’re supposed to be. I pasted the signing key in the OAuth credentials and the upload key is in the keystore file in Unity.
Whenever I test the integration I build an aab via the Unity Editor and upload it to our internal test track where I’m registered as a tester.
I did a lot of google & unity forum research regarding this issue but nothing I found was able to help me. I hope that maybe someone here has any ideas on what could be the problem. Thank you!
Hello @HerrPascal ,
Please note that Google Play Games authentication is different from Google authentication. Please check the google play games compatibility with the id providers in the docs
if you are willing to use GPG v11.01 you can start the fix by using AuthenticationService.Instance.SignInWithGooglePlayGamesAsync
and AuthenticationService.Instance.LinkWithGooglePlayGamesAsync instead
Hello @mahdik_unity
Thanks for the reply! Like I mentioned, I already tried the XWithGooglePlayGamesAsync methods and I get the same error. Also I assume the “main” problem occurs before I even use the Authentication calls, but when I call PlayGamesPlatform.Instance.RequestServerSideAccess
I get the error:
“Requesting Server Side Access Task Failed - Com.Google.Android.GMS.Common.API.APIException 10”
Hi, when i run my game in android the authorization token code show correct in the log, but
AuthenticationService.Instance.SignInWithGooglePlayGamesAsync return error 401 unable to validate token. PERMISSION_DENIED
I use the code from Set up Google Play Games sign-in and
I was facing the same issue, IDs and all the logic were correct. I tried many things to resolve the issue.
I was using authentication v2.2.0 and Play Games Services Plugin v0.11.01.
I removed all GooglePlayGames library from the project and reimported all, used a custom ID class name while setting up Play Games Plugin, and reconfigured PlayGames login credentials in player settings. In addition, I updated the authentication library to v2.3.1 version. It is working as expected. Hope it helps guys.
how the heck do you have the Web Client that’s auto created by Google Service? I’ve seen it generated before for an older project that used Firebase but now that I’m trying to setup with UGS I don’t have this web client credential being created…
Pay close attention to which certificate fingerprint you use in the OAuth credential. There are 2 different ones to choose from: the Upload Key (which signs the app when you build it) and the App Signing Key (which Google uses to sign the app when it distributes it).