question

Jinsu Kim avatar image
Jinsu Kim asked

AuthenticateSessionTicket to Silent Login (with GPGS, Unity)

Client : Unity 2019.4.24f1

Auth : GPGS

1. Initially receive serverAuthCode via GPGS and attempt to log in via LoginWithGoogleAccount.

2. If login is successful, save the playfabId and sessionTicket to Unity PlayerPrefs.

3. When the app is subsequently turned off and on again, call the sessionTicket saved in Unity PlayerPrefs to verify that it has been expired in order to log in without going through GPGS.

4. If sessionTicket is valid, replace sessionTicket with PlayFabSettings.staticPlayer.ClientSessionTicket.

5. but there will be 'PlayFabException: Must be logged in to call this method'.

Is it an error caused by the above process? Or is it from a different code?

I wonder if there is an issue in the above process.

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

·
Sarah Zhang avatar image
Sarah Zhang answered

To implement the silent login, you can consider using our anonymous login mechanisms. For example, if you develop the android application, you can call the LinkAndroidDeviceID to link the player account with the device Id, then in the next time, you can call the API LoginWithAndroidDeviceID silently to log the player in.

If you still want to store the player’s session ticket to skip the login process, we suggest you store the PlayFabAuthenticationContext object directly. You can refer to the script -- InstanceAuthTests to use the predefined authentication context in the PlayFabClientInstanceAPI.

PlayFabSettings.staticPlayer.ClientSessionTicket is not designed for developers to custom the SessionTicket. PlayFabSettings class contains some properties would store that if you have called the login method or not. So, only attaching the value to PlayFabSettings.staticPlayer.ClientSessionTicket won’t create a valid PlayFabAuthenticationContext. You will get the error message – “Must be logged in to call this method”.

10 |1200

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

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.