When you go to get the code from your email, you MUST leave the original interface open. If you close the original screen, it resets everything, and the code will be seen as expired. When you go to get the code, you have to use a second window or a second tab to check your email, then return to the other screen you left open to enter the code.
Or retrieve your email on your phone while leaving the original computer screen open.