question

julian-h avatar image
julian-h asked

AddUsernamePassword gives errors as feedback - Email required / Password required (both are given)

Hello dear humans and others,

new PlayFab user here, so I apologize in advance if I was just to stupid to find the solution :P

I have the following problem:

Upon starting the game I'm currently working on the player can choose between

-LoginWithEmailAddress (obviously just working if the player is already registered)

-RegisterPlayFabUser

-LoginWithCustomID

All three options work perfectly fine. If the player chooses to LoginWithCustomID I want them to be able to later add an email address. I understand that "RegisterPlayFabUser" would now just add an additional player for PlayFab - so my option of choice is AddUserNamePassword with the player giving username, email and password as input just like if they would've registered in the first place.

However now Unity give me these errors:

/Client/AddUsernamePassword: Invalid input parameters
Email: The Email address field is required.
Email: Email address is not valid.
Password: The Password field is required.
Password: Password must be between 6 and 100 characters.
UnityEngine.Debug:LogError(Object)

Both inputs were given and the email address is just as valid as the password has between 6 and 100 characters...

In the official Youtube tutorial given by the "Azure Playfab" channel (Playfab Authentication Series - Part 2) the script shown about 19 minutes in states that these errors are normal and okay if the player was previously logged in (in my case with CustomID) but I just can't wrap my head around how they are okay - especially since there is no email address nor username or password linked to the player shown in my PlayFab Game Manager after doing this.

I hope my problem explanation is clear enough and that somebody is able to help me. I spent 5 hours trying to fix this today and my horrible headache told me to give up for now :D

I appreciate anybody trying to help! If you have further questions I'll gladly provide additional info :)

Have a nice day kind reader!

Julez / RikuNaceLand

Account ManagementAuthentication
10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

We tested this Client API AddUsernamePassword in the external REST API testing tool – Postman. The API works fine. You can click the link to get PlayFab SDK of Postman and use it to test the API before you call it with Unity SDK. We also use the following sample code to test this API in Unity. It can work fine too. Please refer to the code and recheck your Unity code

    void Start()
    {
        PlayFabClientAPI.LoginWithCustomID(new PlayFab.ClientModels.LoginWithCustomIDRequest
        {
            CustomId = "[YourCustomId]",
            CreateAccount = true,
            TitleId = "[YourTitleId]"
        }, result =>
        {
            PlayFabClientAPI.AddUsernamePassword(new PlayFab.ClientModels.AddUsernamePasswordRequest
            {
                Username = "[YourUserName]",
                Email = "XXX@XXX.com",
                Password = "[YourPassword]"
            }, addUsernamePasswordResult =>
             {
                 Debug.Log("Username:" + addUsernamePasswordResult.Username);
             }, Error);
        }, Error);
    }


    private void Error(PlayFabError error)
    {
        Debug.Log(error.GenerateErrorReport());
    }
2 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.

julian-h avatar image julian-h commented ·

Thank you for your help!

Sadly my issue stays the same. I'll gladly share more details - hoping it will help.

Log:

Details:

Code:

I tested the input fields (GetUserEmail, GetUserPassword, GetUserName) by printing their values (userEmail, userPassword, username) to the console. They are receiving their inputs, the entered email is valid (using my work-email) and the password is between 6 and 100 characters.

This is how the initial login-/registration-skip calls a LoginWithCustomIDRequest:

The TitleID has been set before in the Start() function and since this anonymous login always succeeds for me (yeay, this is the working part ^^) I'll just enclose OnSkipSuccess:

The REGISTRATIONSKIPPED key is set in PlayerPrefs for future checks but doesn't change anything here.

To sum this up: Skipping the registration and thus logging in with a CustomID lets the player play the game and creates a visible player in the GameManager. Once I call "OnClickLoginOrRegister" to call "AddUsernamePassword" I get the log messages posted above and upon checking the PlayFab GameManager said user still has no username, password or email connected.

I hope this clarifies my issue...

Thanks in advance for any further help!

0 Likes 0 ·
julian-h avatar image julian-h commented ·

The screenshots were deleted when posting, I uploaded them again but the post with them in it is now "awaiting moderation" just like my initial question did for two days - so yeah...time to wait again, I suppose...

Just stating this here so nobody is confused by my other reply with the missing screenshots (IF this comment is published without "awaiting moderation" first, that is :P

0 Likes 0 ·
julian-h avatar image
julian-h answered

The attached screenshots were deleted, so....new attempt:

@Sarah Zhang - I hope you don't mind me tagging you, if this even works :)


playfab-support.png (79.6 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.

julian-h avatar image
julian-h answered

I know I'm not a paying user of Playfab but have to say I'm still disappointed to not have gotten any new help attempt after more than 7 days...

Trying the tagging thing again, this time properly @Sarah Zhang - sorry to bother you specifically but I have not made contact with anybody else on here yet and apparantly you are "following" this thread anyway

10 |1200

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

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.