question

Ejandra Mae Dimacali avatar image
Ejandra Mae Dimacali asked

Log in Using Google Account in another device

I have a question regarding my implementation. What I am trying to do is a user uses his Google account as his recoverable account in Device1 then he should be able to get the progress he has done in Device2 if he decides to login using the PlayFab account where the google account was linked to. How I do this is that, in Device1 where the first linking of Google Account to Playfab account is done, PlayFabClientAPI.LinkGoogleAccount is used. Then in Device2, when user now chooses to recover his account in Device1 by logging in to PlayFab account where the google account is linked to, PlayFabClientAPI.LoginWithGoogleAccount is used. However, I get error code 1026 - Invalid Google Token when doing so. I have read a similar question here regarding this but I have no idea if this has been resolved or how to actually get around this. I hope you can help me.

6 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.

Seth Du avatar image Seth Du ♦ commented ·

Is Device 2 using the same token as Device 1? I think you need to generate a new token for Device 2

0 Likes 0 ·
Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali Seth Du ♦ commented ·

Is the serverAuthCode the token you are referring to? I use the serverAuthCode for the login and link requests.

0 Likes 0 ·
Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali Seth Du ♦ commented ·

I checked and the serverAuthCode generated in Device1 from Device2 is not similar at all that is if the token you are referring to is the serverAuthCode.

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ commented ·

Are you using Google Play for authentication likeSetting up PlayFab authentication using Google Play games sign-in in Unity? I tried with the latest Unity SDK and it works well.

0 Likes 0 ·
Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali JayZuo ♦ commented ·

Yes I followed this guide with some tweaks only. I use LinkGoogleAccount on Device1 and LogInWithGoogleAccount on the recovery device (Device2).

0 Likes 0 ·
Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali commented ·

I forgot to mention that on Device2 where the error happens, I first use LinkGoogleAccount then if an error that the account is already linked happens, I then use LoginWithGoogleAccount on the error callback so I could log the playfab account where the google account is linked. I am not doing any google reauthentication though, just using the same serverAuthCode in LinkGoogleAccount request. Could that be causing an issue because I sent two Google API related requests using the same serverAuthCode?

0 Likes 0 ·

1 Answer

·
JayZuo avatar image
JayZuo answered

Yes, using the same serverAuthCode twice is the problem here. The server auth code is a one-time-use code. For more details on this flow see: Google Sign-In for Websites.

And to solve this issue, you can Getting another server auth code after exchanging the first code.

PlayGamesPlatform.Instance.GetAnotherServerAuthCode(true, (string serverAuthCode) =>
{
    Debug.Log("New Server Auth Code: " + serverAuthCode);
});
1 comment
10 |1200

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

Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali commented ·

This works! Thank you @Jay Zuo

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.