Verification failed An unknown error occured on sign in

After removing macbook from list of iCloud devices I run this command in terminal and it resolved the issue:

sudo -v ; killall -9 accountsd com.apple.iCloudHelper ; defaults delete MobileMeAccounts ; mkdir ~/Library/Accounts/Backup ; mv ~/Library/Accounts/*.sqlite* ~/Library/Accounts/Backup/ ; killall -9 accountsd com.apple.iCloudHelper ; sudo reboot

I had the exact same error. Here’s how I fixed it:

A corrupt Keychain can prevent multiple services from loggin in, including iCloud. Here is a way to figure out if your Keychain is the cause of not being able to login to iCloud.

  1. Open your Console app (under Utilities)
  2. In the Search field, type "Login"
  3. Press the Clear button.
  4. Try to login to your iCloud.
  5. Note the error messages. They may look something like this"

Error Domain=com.apple.accounts Code=13 UserInfo={NSLocalizedDescription=, NSUnderlyingError=0x7f*******c10 {Error Domain=com.apple.accounts.keychain Code=-25295}}}}

Break down the error codes:

Error Domain=com.apple.accounts Code=13

This code can be linked to Keychain errors with a simple Google search

Error Domain=com.apple.accounts.keychain Code=-25295

This error code (and many others) can be nterpreted at this link:

           https://krypted.com/lists/comprehensive-list-of-mac-os-x-error-codes/

In this case, 25295 is interpreted by pressing Command F and searcing "25295". The search locates the following code:

Keychain Manager error codes

errKCInvalidKeychain = -25295

All indications are that the Keychain is corrupt, blocking services from logging in. In fact, by searching your own Apple ID in the keychain to locate login keys, you might try deleting Public keys. In doing so, MacOS will fail to delete any key that is corrupt.

SOLUTION:

The solution is at this link: How to back up your iCloud Keychain

https://eclecticlight.co/2019/09/05/how-to-back-up-your-icloud-keychain/

If you backup your MacOS device, your Keychain is also backed up. The article describes how to ensure your iCloud keychain items are also included in any local backup, and in doing so, it also describes how to restore your Keychain. Your Keychain is located in a file within your Library at ~/Library/Keychains. In finder, you need to select GO at the top menu (there's a way to unhide the "Go" tab... I don't remember offhand, but it is easy to find). Library is under the GO tab. This being said, this folder is also backed up to Time Machine or any duplicate of your MacOS device. Follow the instructions in the link to restore the ~/Library/Keychains folder to your MacOS device. I restarted my MacBook Pro, at this point, and for the first time in a couple of weeks, was able to login to all services. Problem solved!