Welcome to Android Central.
Even without much explanation I know exactly what you're talking about. It is so annoying, or it was until I understood what was going on.
I think you have a few options,
Turn off 2 step authentication. Log into your Google account on a laptop or PC, those are the easiest because I think you'll still need your phone to do this, and turn off 2-step until you get your device set-up.
Transfer to another device. If you're using the Authenticator app you can transfer it to another device or use it on one device while setting up the other. This was my preferred method. You can put it on any device that is compatible, you could even use a much older device as long as it can download the app.
Beat the clock. In the Authenticator app if you touch and hold the code it will save it to your clipboard then you can paste it in the spot when you get there. Of course you kind of have to be on your game for this approach cause you have to save the number as soon as it pops up and then be back at the log in screen within the time limit of the code. I have also found that there seems to be a 5 or so second reprieve where it still takes the code even a few seconds after the minute it gives you. I've done this one a time or two before realizing that I could use the app on another device.
G-code backups. If you go to 2-step online you'll find a list of codes that start with G- these seem to be stagnant codes that you can use without a device. I've never tried this one but I figure if the previous method worked this should also. Then use the G- code to log in.
Let us know what you find and if I guessed your issue correctly. If not please fill in the details so that we can better help you.