question

ben avatar image
ben asked

LoginWithGoogleAccountRequest: One of the following properties must be defined: ServerAuthCode, AccessToken, Encrypte dRequest

hey everyone, this is the first time we use playfab for our game, we tried to make the game connect to user's google play account, we already follow everything from the tutorial on here

https://api.playfab.com/docs/tutorials/landing-players/sign-in-with-google

the google [play plugin works just fine, i can login with no problem, the problem came after that, it just wont connect to play fab, heres a snippet of the code

public void Login()
    {
        Social.localUser.Authenticate((bool success) => {
            if (success)
            {
		/// tried both, wont work
		//LoginPlayfab();
                Invoke("LoginPlayfab", 0.25f);
            }
            else
            {
                
            }
        });
    }


public void LoginPlayfab()
    {
#if UNITY_ANDROID
        var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
        Debug.Log("Server Auth Code: " + serverAuthCode);

        PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
        {
            TitleId = PlayFabSettings.TitleId,
            ServerAuthCode = serverAuthCode,
            CreateAccount = true
        }, (result) =>
        {
            OnLoginSuccess(result);

        }, OnLoginFailure);
#endif
#if UNITY_IOS
        PlayFabClientAPI.LoginWithGameCenter(new LoginWithGameCenterRequest()
        {
            TitleId = PlayFabSettings.TitleId,
            CreateAccount = true
        }, (result) =>
        {
            OnLoginSuccess(result);

        }, OnLoginFailure);
#endif
    }

and heres the logcat error log

04-03 12:21:19.416  2445  2460 E Unity   : SocialManager:OnLoginFailure(PlayFabE
rror)
04-03 12:21:19.416  2445  2460 E Unity   : PlayFab.Internal.<MakeApiCall>c__Anon
Storey3:<>m__0(String)
04-03 12:21:19.416  2445  2460 E Unity   : PlayFab.Internal.<PostPlayFabApiCall>
c__Iterator1:MoveNext()
04-03 12:21:19.416  2445  2460 E Unity   : UnityEngine.SetupCoroutine:InvokeMove
Next(IEnumerator, IntPtr)
04-03 12:21:19.416  2445  2460 E Unity   :
04-03 12:21:19.416  2445  2460 E Unity   : (Filename: ./artifacts/generated/Andr
oid/runtime/DebugBindings.gen.cpp Line: 51)
04-03 12:21:19.416  2445  2460 E Unity   :
04-03 12:21:19.420  2445  2460 E Unity   : /Client/LoginWithGoogleAccount: Inval
id input parameters
04-03 12:21:19.420  2445  2460 E Unity   : LoginWithGoogleAccountRequest: One of
 the following properties must be defined: ServerAuthCode, AccessToken, Encrypte
dRequest
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

·
brendan avatar image
brendan answered

What are you passing into the call? In almost every case, you should be using the ServerAuthCode you get from Google to sign the player in, with that API method.

3 comments
10 |1200

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

ben avatar image ben commented ·

yes, i already use the

        var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
        Debug.Log("Server Auth Code: " + serverAuthCode);
 
        PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
        {
            TitleId = PlayFabSettings.TitleId,
            ServerAuthCode = serverAuthCode,
            CreateAccount = true
        }, (result) =>
        {
            OnLoginSuccess(result);
 
        }, OnLoginFailure);

and i just rechecked the catlog, it seems the server auth code is empty

04-03 12:21:18.138  2445  2460 I Unity   : Server Auth Code:

which is i dunno why, since the Google Play login is completely fine

0 Likes 0 ·
brendan avatar image brendan ben commented ·

If the call to the PlayGamesPlatform service is returning null for the server auth code, I'd have to recommend having a look at one of the threads in their support on this issue (ex: https://github.com/playgameservices/play-games-plugin-for-unity/issues/1732)

0 Likes 0 ·
Mahnoor Naeem avatar image Mahnoor Naeem brendan commented ·

this one is solved?

0 Likes 0 ·

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.