private void AddAccountAndPassword() { //Any time we attempt to register a player, first silently authenticate the player. //This will retain the players True Origination (Android, iOS, Desktop) SilentlyAuthenticate((result) => { if (result == null) { //something went wrong with Silent Authentication, Check the debug console. OnPlayFabError.Invoke(new PlayFabError() { Error = PlayFabErrorCode.UnknownError, ErrorMessage = "Silent Authentication by Device failed" }) ; Debug.Log("Result is null for silent authentication."); } Debug.Log(result); //Note: If silent auth is success, which is should always be and the following //below code fails because of some error returned by the server ( like invalid email or bad password ) //this is okay, because the next attempt will still use the same silent account that was already created. //Now add our username & password. PlayFabClientAPI.AddUsernamePassword(new AddUsernamePasswordRequest() { Username = !string.IsNullOrEmpty(Username) ? Username : result.PlayFabId, //Because it is required & Unique and not supplied by User. Email = Email, Password = Password, }, (addResult) => { if (OnLoginSuccess != null) { var currentPlayer = new PlayerInfo { EntityToken = result.EntityToken.EntityToken, PlayFabId = result.PlayFabId, SessionTicket = result.SessionTicket }; //Store identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; //Override the auth type to ensure next login is using this auth type. AuthType = Authtypes.EmailAndPassword; Debug.Log("Before updating email"); AddOrUpdateContactEmail(Email); LinkDeviceId(); Debug.Log("After Updating email"); //Report login result back to subscriber. OnLoginSuccess.Invoke(result); } }, (error) => { if (OnPlayFabError != null) { //Report error result back to subscriber OnPlayFabError.Invoke(error); Signals.Get<PlayFabErrorSignal>().Dispatch(error.Error); } }); }); }
However I get the following error.
/Client/AddUsernamePassword: User already linked to a different account
When the device isn't linked to any account, the signing up successfully works. I even have a sign out feature which basically unlinks the user. However how can I unlink an account before running this
AddAccountAndPassword() function.