I had the same problem with the endless loop. I tried appending the code to my password, but that did not work.
I found the fix that worked for me on another thread: before going through the two-factor sign-in process on my AppleTV, I had to sign out of my iTunes account on my AppleTV. (I was still signed in from before I adopted the two-factor authentication process.)
Once I signed out, I then signed back in by entering ONLY my password on the password screen and then entered the six-digit verification code on its separate screen. Worked on the first try. Not sure what generation my AppleTV is.
I read that for some older generations or for those running older software, there is no separate verification code screen. In that case, I suppose one would have to go the route of appending the six-digit verification code to one’s password screen.
Keep in mind the six-digit verification code expires quickly after you press the “ok” button beneath it on your phone, iPad, or whatever other device you generate it on.
Hope this helps someone. Good luck and sorry for the long post.