playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.43k stars 954 forks source link

Player ID vs Google ID #3079

Closed gustavovendramini closed 2 years ago

gustavovendramini commented 2 years ago

After authentication, I'm able to get the user_id and the id_token

PlayGamesPlatform.Instance.GetUserId()
PlayGamesPlatform.Instance.GetIdToken()

I'm going to call the return of GetUserId() as "Player ID".

The "Player ID" that I get is following this pattern: g079327****2859018803

But, when the backend server validates the id_token I get the following user id 1090167****5617714260, I think this is the "google web user-id"

Maybe related to https://github.com/playgameservices/play-games-plugin-for-unity/issues/3068 @smile616

smile616 commented 2 years ago

Het @gustavovendramini,

Why the method GetUserId() doesn't return the "google web user-id"?

That's by design, GetUserId return Play Games services id for user signed in with Play Games services and linked to Play Games profile. See:

Is possible to obtain the "google web user-id" on PlayGamesPlatform?

Assuming you are talking about ID token is a JSON Web Token signed by Google that can be used to identify a user to a backend.. PlayGamesPlatform.Instance.GetIdToken() does exactly that, see:

Is there some token that the server can parse and obtain the "Player ID"?

You can use REST API as described at https://developers.google.com/games/services/web/api/players/get#request. You will need to get an auth token using PlayGamesPlatform.Instance.GetServerAuthCode(). Don't forget to call .RequestServerAuthCode(true) when creating PlayGamesClientConfiguration otherwise GetServerAuthCode() will not be populated.

Is the "Player ID" unique for the google account?

It is unique in sense that two different the google account will always have different player ids. The Player Id may change for given google account, for example, when use deletes their Play Games profile and create a new one later.

Maybe related to #3068

no, it's unrelated to that issue.