playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.44k stars 959 forks source link

How to retrieve new idToken after expiry? #3021

Open VirtualAutonomy opened 3 years ago

VirtualAutonomy commented 3 years ago

I'm attempting to renew the idToken retrieved via PlayGamesServices using:

Social.localUser.Authenticate ... idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();

When I attempt to retrieve the new idToken, it instead only shows the original, which inevitably has expired. In essence, I'm attempting to re-authenticate but it's not producing a new, valid, token.

What does best practice look like for retrieving a new token in advance of the original expiry?

I'm sending the idToken to my server for verification purposes rather than the authToken as otherwise I'd need to request extra scopes like profile information and/or email. Is there a way to retrieve another idToken while logged in to Play Services or is the intention for developers to assign their own refresh tokens for this purpose?

Edit: The only way to do this seems to involve logging out and in again. This is fine but it always shows the notification at the top of the screen unless you add .EnableHidePopups() in the PlayGamesClientConfiguration.Builder()

miskiewicz commented 3 years ago

Hi. Have you found any other solution than logging out? There should be a way to get a new token if the original one has expired.

This problem also being reported in this issue #3030