question

Michael avatar image
Michael asked

Not getting the server auth code when trying to sign-in using google.

Hello @Rick Chen ,@Sarah Zhang and @Citrus Yan, I am trying to request and get the server auth code after completing the google play games sign-in but it is giving me the error that says:- "[Play Games Plugin 0.11.01] ERROR: Requesting server side access task failed - com.google.android.gms.common.api.ApiException: 10: System.Action:Invoke()" Any idea to resolve this and get the server to auth code for the login in Playfab using Google? And my code is below:-

     private void OnSignInButtonClicked()
         {
             PlayGamesPlatform pGamePlatform = PlayGamesPlatform.Activate();
             if (!Social.localUser.authenticated)
             {
                 pGamePlatform.Authenticate((SignInStatus success) =>
                 {
                     Debug.Log("SignInStatus is" + success);
        
                     if (success == SignInStatus.Success)
                     {
                         GoogleStatusText.text = "Google Signed In";
                         StartCoroutine(GetAuthCode());
                     }
                     else
                     {
                         GoogleStatusText.text ="Google Failed to Authorize your login";
                     }
                 });
             }
         }
        
        
        
     void GetAuthCode()
         {
             PlayGamesPlatform.Instance.RequestServerSideAccess(true, code =>
             {
                 Debug.Log("Authorization code: " + code);
                 Token = code;
                 GotAuthCode();
             });
         }
        
        
        
     void GotAuthCode()
         {
             if (Token != null && Token.Length > 0)
             {
                 PlayFabClientAPI.LoginWithGooglePlayGamesServices(new LoginWithGooglePlayGamesServicesRequest()
                 {
                     TitleId = PlayFabSettings.TitleId,
                     ServerAuthCode = Token,
                     CreateAccount = true
                 }, (result) =>
                 {
                     GoogleStatusText.text = "Signed In as " + result.PlayFabId;
                 }, (OnPlayFabError) =>
                 {
                     GoogleStatusText.text = "Signed In failed";
                     Debug.LogError(OnPlayFabError.Error);
                 });
             }
             else
             {
                 GoogleStatusText.text = "not getting the server auth code";
                 Debug.Log("not getting the server auth code");
             }
         }
apis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

According to the Why do I get com.google.android.gms.common.api.ApiException: 10, it seems that you don’t set the correct web application client id. The play-games -for-unity plugin also mentions that if you need a server auth code to be exchanged for an access token by the backend server, you need to set web application client id. We recommend that you check that this setting is correct and try again. And since we are not expert of Google Android development, you may need to seek professional help from Google.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.