This happened to me the other night ... System Preferences suddenly alerted me (Sierra 10.12) that I needed to log into a couple of places in Sys Prefs~>Internet Accounts. Like your scenario the passwords were rejected despite working on the actual websites in question. I removed the accounts in Sys Prefs, logged out then back in & the issue seemed to resolve itself & the passwords were accepted.
At the same time as the issue presented, I received an email from iCloud regarding the following link.
Using app-specific passwords
This may or may not be the issue you are having but try what I suggested as it worked in my case.