I'm trying to save player data to a playfab account created from a google login. The google login process appears to be working almost ok, I can see my achievements and the login icon, but when I try to get the ServerAuthCode it's always empty.
This is my current code:
public class Achievements : MonoBehaviour { public PlayFabLogin PlayFabLogin; #if UNITY_ANDROID PlayGamesClientConfiguration config; #endif #if UNITY_ANDROID || UNITY_IOS void Start () { #if UNITY_ANDROID if (PlayGamesPlatform.Instance.localUser.authenticated) return; config = new PlayGamesClientConfiguration.Builder() /*.AddOauthScope("profile") .AddOauthScope("email") .RequestIdToken()*/ .RequestServerAuthCode(false) .Build(); PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); PlayGamesPlatform.Instance.SignOut(); #elif UNITY_IOS if (Social.localUser.authenticated) return; #endif SignIn(); } #endif void SignIn() { #if UNITY_ANDROID || UNITY_IOS Social.localUser.Authenticate((bool success, string error) => { if (success) { #if UNITY_ANDROID StartCoroutine(PlayFabLogin.LoginGoogle(config)); #endif } else { Debug.LogError("Login-Google login failed: " + error); } }); #endif } } And the PlayfabLogin class: public class PlayFabLogin : MonoBehaviour { public InputField EmailInputField, UsernameInputField, PasswordInputField; #if !DISABLESTEAMWORKS LoginWithSteamRequest request; #elif UNITY_IOS || UNITY_TVOS || UNITY_STANDALONE_OSX LoginWithGameCenterRequest request; #elif UNITY_XBOXONE //LoginWithXboxRequest request; #endif public void Start() { #if !DISABLESTEAMWORKS request = new LoginWithSteamRequest(); PlayFabClientAPI.LoginWithSteam(request, OnLoginSuccess, OnLoginFailure); #elif UNITY_ANDROID //LoginGoogle(); #elif UNITY_IOS || UNITY_TVOS || UNITY_STANDALONE_OSX request = new LoginWithGameCenterRequest(); request.CreateAccount = true; PlayFabClientAPI.LoginWithGameCenter(request, OnLoginSuccess, OnLoginFailure); #elif UNITY_XBOXONE request = new LoginWithXboxRequest(); request.CreateAccount = true; PlayFabClientAPI.LoginWithXbox(request, OnLoginSuccess, OnLoginFailure); #endif } #if UNITY_ANDROID public IEnumerator LoginGoogle(PlayGamesClientConfiguration config) { yield return new WaitForSecondsRealtime(5); string serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode(); Debug.Log("Login-LoginGoogle-Login with serverAuthCode: " + serverAuthCode); LoginWithGoogleAccountRequest request; request = new LoginWithGoogleAccountRequest() { TitleId = PlayFabSettings.TitleId, CreateAccount = true, ServerAuthCode = serverAuthCode }; } #endif private void OnLoginSuccess(LoginResult result) { Debug.Log("Congratulations, you made your first successful API call!\n Signed In as" + result.PlayFabId); } private void OnLoginFailure(PlayFabError error) { Debug.LogWarning("Something went wrong with your first API call. :("); Debug.LogError("Here's some debug information:"); Debug.LogError(error.GenerateErrorReport()); } }
asd