In AppleScript when entering password, is a click required
Try adding this to your code:

set first responder to text field 2 of window 1


This should bring focus to the text field.

For reference, see this post on MacScripter