question

dediub avatar image
dediub asked

username contains invalid characters

Why? i can't understand why i get all the time this error. I'm using a TextMeshProUGUI to obtain the username, email and password but always I get this error.

The weird case is, when I put a string with hardcoding inside the function AddUsernamePassword() it Works with the same name i typed in the input field.

public void SingInNewAccountPlayFab(string username, string password, string email)
    {
        Debug.Log("username: " + username);
        Debug.Log("password: " + password);
        Debug.Log("email: " + email);
        PlayFabClientAPI.AddUsernamePassword(new AddUsernamePasswordRequest()
        {
            Username = username, // if i type Username = "Whatever" Works but It isn't 
					if i take it from  username parameter
            Password = password,
            Email = email
        }, result =>
        {
            if (SceneManager.GetActiveScene().name == "Menu")
            {
                GameObject menu = GameObject.Find("OptionsPanel");
                menu.GetComponent<UIPlayfabRegister>().WritePopUpPanel("Account added, now you will preserve all your content.");
                menu.GetComponent<UIPlayfabRegister>().CloseIfRegistered();
                UserSettingsRepository.Instance.UserData.username = username;
                UserSettingsRepository.Instance.UserData.password = password;
                UserSettingsRepository.Instance.UserData.email = email;
                UserSettingsRepository.Instance.Save();
            }
            AuthenticateWithPlayFabClient(username, password);
        }, OnPlayFabError);
        
    }

aaaa.png (251.9 KiB)
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

·
dediub avatar image
dediub answered

Fixed, the problema was the… (imagine the worst and ugly Word) Textmespro input field. Unity tends to add a White space at the end of their input field .text strings. Thats why I got the error.

Don't try to remove that White space with .Trim() because it doesn't work either. I had to do a .Remove(string.length -1) and it Works correctly now.

Take care!!!

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.

Citrus Yan avatar image Citrus Yan commented ·

Thanks for the heads up:)

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.