Sign In Register

How can we help you today?

Start a new topic

[Unity] override player with GPGS account loads old user

I have a fresh account with only deviceID and I have another account with some progress on it which is linked with google. When I try to link fresh account with the same google account It sometimes does not reload the user.


Here is my GooglePlayConnectRequest

  

public void GooglePlayConnect(string code, Action successCallback, Action failCallback = null,
        bool setErrorOnSwitch = false, bool switchIfPossible = false)
    {

        string displayName = GooglePlayGames.PlayGamesPlatform.Instance.GetUserDisplayName();

        new GooglePlayConnectRequest(GS.Instance)
            .SetCode(code)
            .SetRedirectUri("http://www.gamesparks.com/oauth2callback")
            .SetDisplayName("Test")
            .SetErrorOnSwitch(setErrorOnSwitch)
            .SetSwitchIfPossible(switchIfPossible)
            .SetDoNotLinkToCurrentPlayer(false)
            .Send(
            response =>
            {
                Debug.Log("GPGS GS AUTHENTICATED!");
                if (User.LocalUser != null
                    && String.IsNullOrEmpty(User.LocalUser.GooglePlayId))
                {
                    AddUserSocialID();
                }
                if (successCallback != null)
                {
                    successCallback();
                }
            },
            response =>
            {
                if(switchIfPossible)
                { 
                    Debug.LogWarning("GooglePlayConnectRequest failed! Probably account linked to another user. " + response.Errors.JSON);
                }
                else
                {
                    Debug.LogWarning("GooglePlayConnectRequest failed " + response.Errors.JSON);
                }

                if (failCallback != null)
                {
                    if(response.ScriptData != null)
                        Debug.Log(response.ScriptData.JSON);
                    failCallback();
                }
            });

    }

  

After I connect to google play I call GooglePlayConnect with SetSwitchIfPossible is set to false. I display a popup that any progess will be overriden. Then I call GooglePlayConnect with SetSwitchIfPossible set to true. And finally I call GetUserRequest (no failCallbacks). This sometimes results in user not switching so I end up with fresh account.


Any progress on that? I am able to track the logs and in AuthenticationResponse get the name of user to which is supposed to switch.

Hi Jakub,


Sorry for the delay in getting back to you on this. Just to confirm your issue. You're starting with two accounts, one account is new (no progress data) and one with progress data. The latter of these is connected with a google play account. You are trying to move this linked social account to the new player account, the one without any data? And when you SetSwitchIfPossible to true you end up linked to a fresh account / a brand new player account altogether? Can I confirm that the account you're trying to link the social account to is authenticated when this request is performed?


If the current player has not authenticated and the Google Play user is not known, a new player will be created using the Google Play details and the session will be authenticated against the new player.  If the Google Play user is already known, the session will switch to being the previously created user.


Kind regards,

 - Steve



I did more tests. It does not matter if the first account is fresh or with progress and google play linked. When I try to switch to another account (SetSwitchIfPossible to true) with google play linked and some progress on it I end up with the first account (it suppose to switch accounts).

Login to post a comment