Yahoo! two-step authentication with iOS Mail and Apple Mail
When you sign in with third party apps into Yahoo Account, the password you have to give is not the account password that you use , instead you have to use a key which is provided by yahoo for that particular third party application.

ie, in Yahoo Account Security Settings you have to generate a key for each application which you use to login the Yahoo Account. Next time during login to Yahoo Account through application you have to give this key in place of your password.
More details in Yahoo Account Security Setting https://help.yahoo.com/kb/SLN15241.html
Hope this helps