Welcome to the Apple community.
If you are using two-factor authentication on an older device…
You should be able to append the code to your password and enter that (i.e. if your password is ABC and your code is 123, enter ABC123), however if this doesn't work it may be that you are running out of time (30s) using your authentication code and you may want to delay getting your code until the last minute or temporarily disable the 2 step verification/2 factor authentication, although it shouldn’t be necessary.
Get a verification code and sign in with two-factor authentication
The following was posted by another user…
- From an iPhone or iPad, go into "Settings" => click on the top bar with your name and "Apple ID, iCloud, iTunes & App Store".
- While still on iPhone or iPad, tap on "Password & Security", then tap on "Get Verification Code", LEAVE the supplied verification code visible.
- Go to the iTunes login on your AppleTV settings and start logging in.
- When it asks for your password, enter your password and add the verification code to the end of your password BUT DO NOT HIT SUBMIT YET !!!
- Go back to your iPhone/iPad and tap on "OK" on the verification code to make it go away.
- Now go back to your AppleTV and submit the password.