Dear support team,
I tried to implement the login with Google Play Games as the tutorial in here:
It is working well for the first time when an user logins the app. And I want to develop the automatically login when the user opens the app in the next time and don't need to accept the condition.
In order to do like this, I stored the access token using PlayerPrefs in Unity and when the user opens the app then the Login() function is called and uses the access token to login.
In details, I stored string accessToken = AccessToken.CurrentAccessToken.TokenString; with Facebook Login while string serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode(); is saved in Google Login. You can see the source below as the reference.
However, it is only working well with Facebook login method and it had the issue with Google login. When the user opens the app in the next time, the Login() function is called then the error - InvalidGoogleToken happened. I guess that serverAuthCode is changed and invalid. So do you have any solution for this issue?
Thank you so much for your support!!!
//Login with Facebook string accessToken = AccessToken.CurrentAccessToken.TokenString; string userID = AccessToken.CurrentAccessToken.UserId; // Store the AccessToken in PlayerPrefs PlayfabManager.PlayFab.account.SetFacebookToken(userID, accessToken); // Call LoginWithFacebook() Playfab API PlayfabManager.PlayFab.LoginWithFacebook(accessToken, AfterLoginAction, errorCallbackFacebookLogin);
// Login with Google Play Games string serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode(); string email = PlayGamesPlatform.Instance.GetUserEmail(); // Store the serverAuthCode in PlayerPrefs PlayfabManager.PlayFab.account.SetGoogleToken(email, serverAuthCode); // Call LoginWithGoogleAccount() Playfab API PlayfabManager.PlayFab.LoginWithGoogle(serverAuthCode, AfterLoginAction, errorCallbackGoogleLogin);
// For automatically login public void Login(Action<LoginResult> successCallback, Action<PlayFabError> errorCallback) { switch (account.memberType) { case EMemberType.Google: LoginWithGoogle(account.GoogleToken, successCallback, errorCallback); break; case EMemberType.Facebook: LoginWithFacebook(account.FacebookToken, successCallback, errorCallbac k); break; } }