playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.45k stars 963 forks source link

Unity Plugin Player ID x Google API Player ID #3212

Closed PSDevStudio closed 1 year ago

PSDevStudio commented 1 year ago

Hello everyone,

I have a problem when trying to match the player ID returned from the Unity play games plugin, to the player ID returned from Google API call. See details below;

Client Side - Unity SDK new login instructions as per 0.11.01;

PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);

internal void ProcessAuthentication(SignInStatus status)
    {
        if (status == SignInStatus.Success)
        {
            Debug.Log($"UserDisplayName -> {PlayGamesPlatform.Instance.GetUserDisplayName()} - ID -> {PlayGamesPlatform.Instance.GetUserId()} / {PlayGamesPlatform.Instance.localUser.id});
        }
    }

Both return the ID on the format of 21 numeric digits, for example -> 123456789012345678901

Then, I fetch the server side auth code in Unity using the following code, also from the documentation;

PlayGamesPlatform.Instance.RequestServerSideAccess(false, code =>
            {
                Debug.Log($"Server Auth Code -> {code}");
            });

Then, I pass this auth code to my backend server and correctly exchange it for an access token, which then I use the following API to verify the authenticity of the request -> https://developers.google.com/games/services/web/api/applications/verify Everything works perfectly, except that one of the properties of the response is the player ID which the authentication is meant to be given, but that code is different than the one returned in Unity SDK.

That one also has 21 characters, but they are on the following format;

{
    "player_id": "g09876543211234567890",
    "kind": "games#applicationVerifyResponse"
}

I'd like to be able to get the same player or user id on both platforms, but so far I haven't managed to find any method in either end to achieve this result, or to find a reason why this is happening.

I found several reports online for situation like this few years ago when Google apparently had performed this change, but they were the other way around. In any case, none of the answers were satisfactory or explanatory on why these differences happens.

Any chance somebody came to this scenario already?