not sure how to use the unity Authentication.

I need help with the unity authentication sdk, specifically the username and password branch of it. The docs go over what functions to use but as a beginner they are not in depth enough. I have TMP input systems set up for the username and passwords and I have buttons to submit them but when click the submit button I get this error:

NullReferenceException: Object reference not set to an instance of an object
signin.SignUp () (at Assets/graphs/signin.cs:42)

and this is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Services.Core;
using Unity.Services.Authentication;
using System.Threading.Tasks;
using TMPro;
using UnityEngine.UI;

public class signin : MonoBehaviour
{
    [SerializeField]
    private TMP_InputField usernameinput;
  
    [SerializeField]
    private TMP_InputField passwordinput;

  
    [SerializeField]
    private TMP_InputField newusernameinput;
  
    [SerializeField]
    private TMP_InputField newpasswordinput;


    private async void Start()
    {
        await UnityServices.InitializeAsync();
        Debug.Log(UnityServices.State);

        SetupEvents();

    }

    public async void login()
    {
        await SignInWithUsernamePasswordAsync(usernameinput.text, passwordinput.text);
    }

    public async void SignUp()
    {
        await SignUpWithUsernamePasswordAsync(newusernameinput.text, newpasswordinput.text);
    }

    // Setup authentication event handlers if desired
    void SetupEvents() {
     AuthenticationService.Instance.SignedIn += () => {
     // Shows how to get a playerID
     Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}");

        // Shows how to get an access token
        Debug.Log($"Access Token: {AuthenticationService.Instance.AccessToken}");

    };

    AuthenticationService.Instance.SignInFailed += (err) => {
        Debug.LogError(err);
    };

    AuthenticationService.Instance.SignedOut += () => {
        Debug.Log("Player signed out.");
    };

    AuthenticationService.Instance.Expired += () =>
        {
            Debug.Log("Player session could not be refreshed and expired.");
        };
    }


    async Task SignUpWithUsernamePasswordAsync(string username, string password)
{
    try
    {
        await AuthenticationService.Instance.SignUpWithUsernamePasswordAsync(username, password);
        Debug.Log("SignUp is successful.");
    }
    catch (AuthenticationException ex)
    {
        // Compare error code to AuthenticationErrorCodes
        // Notify the player with the proper error message
        Debug.LogException(ex);
    }
    catch (RequestFailedException ex)
    {
        // Compare error code to CommonErrorCodes
        // Notify the player with the proper error message
        Debug.LogException(ex);
    }
}

async Task SignInWithUsernamePasswordAsync(string username, string password)
{
    try
    {
        await AuthenticationService.Instance.SignInWithUsernamePasswordAsync(username, password);
        Debug.Log("SignIn is successful.");
    }
    catch (AuthenticationException ex)
    {
        // Compare error code to AuthenticationErrorCodes
        // Notify the player with the proper error message
        Debug.LogException(ex);
    }
    catch (RequestFailedException ex)
    {
        // Compare error code to CommonErrorCodes
        // Notify the player with the proper error message
        Debug.LogException(ex);
    }
}
}

please help as I want the game done by mid august

thanks,
Mariomastr

signin.SignUp () (at Assets/graphs/signin.cs:42)
This part shows you what code caused the error
signin.cs, on line 42

NullReferenceException: Object reference not set to an instance of an object
This shows what kind of error, in this case you’re trying to do something with a reference that doesn’t point to an actually created object. So look on the line and see what objects you’re working with, and make sure they’re set. Probably you can see in the Inspector that those fields are unset

ok thank you but I’m not quite sure that I understand

In line 42 of the script, you’re trying to get the .text field of the variable named newusernameinput. You declared on line 20 that newusernameinput exists, and that is a TMP_InputField type. But from the error message, it seems like the variable you created is never pointed to a valid instance of its type. If you are following a tutorial, probably you are meant to assign the reference by clicking the gameobejct in the editor, viewing the inspector window, and dragging in a TMP_InputField onto the box. But just viewing this script in the scene view/inspector will probably show the fields are not assigned properly

I wonder if I frogot to declaire it in the editor. thank you.