question

MoonHeonYoung avatar image
MoonHeonYoung asked

Google login question

#1

I wrote the code above to receive a new session ticket within 24 hours.

(using Unity + Play Store Mobile + Google Login)

But the code above doesn't seem to work.

When the playtime of my game users exceeds 24 hours, there is a situation where the data cannot be saved.

Is there a problem with my code?

It is an emergency problem.

' Social.localUser.Authenticate(); '

Should I use this function only the first time I log in?

When I log in again, Should I just call PlayFabClientAPI.LoginWithGoogleAccount()?

But that api requires ServerAuthCode.

Do I need to call Google API again to get ServerAuthCode?

(call Social.localUser.Authenticate(); again and call .GetServerAuthCode())

(Parameter required when calling LoginWithGoogleAccount)

#2

var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();

1. In the above Google API code, does serverAuthCode have an expiration date? (Like PlayFab's session ticket)

2. If there is no expiration period, can i reuse the previous authcode?

To test the code above, I have to upload it to Google Play, so it will take a long time, so I ask you a question.

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

·
Rick Chen avatar image
Rick Chen answered

The Social.localUser.Authenticate is not a method from PlayFab SDK, it is a Unity’s method. Please search for the Unity forum for help. You may also find it helpful in this resolved thread with similar issue.

The serverAuthCode from google may have expiration date, it is not recommended to use the previous authcode. If you would like to login the PlayFab account without using google server AuthCode multiple times, you could bind the PlayFab Account with a device id, then you could login to that account with the device id. For more detail, please refer to: Account linking quickstart

4 comments
10 |1200

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

MoonHeonYoung avatar image MoonHeonYoung commented ·

My code above is a modified example code of PlayFab's Google login.

I can't find the answer I'm looking for on Unity forums or other sites.

Your link thread doesn't have what I want.

Google first login is ok works well(using above code), but players must log in again before session ticket expiration

(Log in to LoginWithGoogleAccount again, not log in using the device ID like anonymous)

However, if i reuse the code i used when logging in for the first time, it will not work.

No matter how much I search, I can't find what I'm looking for

(as results of searching for several hours)

I just have to renew my session ticket 24 hours in advance.

please little helps

If i pass the authticket, the LoginWithGoogleAccount function will succeed.

However, is it possible to use the authticket that was used when logging in for the first time 10 hours after the first login?

(by caching)

If not, how do I update the authticket, Google login api call again? Or a specific function?

How did other people (using GooglePlay-Playfab) solve this problem?

0 Likes 0 ·
MoonHeonYoung avatar image MoonHeonYoung commented ·

https://community.playfab.com/questions/29191/clientloginwithgoogleaccount-google-api-error-code-1.html

hm,okay, I understood that serverAuthcode is a one-time-use-code that can only be used when running an app(not twice).

So, can't I use LoginWithGoogleAccount to log in again before the session ticket expires?

As a result of the test, invalid_grant details error occur.

Do I have to find another re-login solution??

I think this google re-login relevant information on this issue should be listed in the Google-Login document(i think this is outdated because google console has renewed recently)

I have gotten a lot of user complaints about this.

situation where users play for more than 24 hours can happen, and developer(like me) need to be aware of the problem.

0 Likes 0 ·
MoonHeonYoung avatar image MoonHeonYoung MoonHeonYoung commented ·

https://community.playfab.com/questions/12038/authenticate-via-google-serverauthcode-issues.html

and this thread is related and helpful for now i'm looking for a device id login method

that is

it is impossible to re-login using LoginWithGoogleAccount

use another method (for other has simillar issue)

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ MoonHeonYoung commented ·

If you are using Google Play Games plugin for Unity, you should be able to get a new "serverAuthCode" with GetAnotherServerAuthCode method as https://github.com/playgameservices/play-games-plugin-for-unity#getting-another-server-auth-code-after-exchanging-the-first-code.

0 Likes 0 ·

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.