Filling the inputs of SecurityAgent if they exist? I am trying to automate the export of my keychains (system and user), and while my script works if I remove the set values, it does not after adding them.

The error I am receiving is

System Events got an error: Can’t get text field 1 of group 1 of window 1 of process "SecurityAgent". Invalid index.


It seems that I am asking for something that doesn't exist? Here is the modal



And here is the code.

tell application "System Events"
    repeat while exists (processes where name is "SecurityAgent")
        tell process "SecurityAgent"
            set value of text field 1 of group 1 of window 1 to "adminuser"
            set value of text field 2 of group 1 of window 1 to "adminpass"
            click button "Allow" of group 1 of window 1
        end tell
        delay 0.2
    end repeat
end tell


If possible I would like to detect if there are fields prior to attempting to set so this can work with or without password prompting
This worked

set appName to "username"
set appPass to "password"

tell application "System Events"
    repeat while exists (processes where name is "SecurityAgent")
        tell process "SecurityAgent"
            if exists (text field 1 of window 1) then
                set value of text field 1 of window 1 to appName
                set value of text field 2 of window 1 to appPass
            end if
            click button "Allow" of group 1 of window 1
        end tell
        delay 0.2
    end repeat
end tell