Like most other 2FA implementations, Yahoo also supports "App Passwords" for apps and APIs which do not have a proper login system to authorize the 2-factor login.
These are static passwords which work as if there's no 2FA implemented at all. Be sure to never share such password with anybody as it bypasses the 2FA.
Yahoo has detailed steps to generate the App Passwords. So, follow the steps to get started:
- Sign in and go to your Account security page.
- Click Generate app password or Manage app passwords.
- Select your app from the drop-down menu and click Generate.
- Follow the instructions below the password.
- Click Done.
- Use this app password and your email address to sign in to your email app.
For more details, visit the Yahoo website - https://help.yahoo.com/kb/SLN15241.html