What's the right approach to run tests with 2-factor authentication?

I'm not sure if this question fits here but let's give it: what's the best way to automate testing when login requires 2-factor authentication?