Error using SecAddSharedWebCredential (add/update/remove account from keychain)

I need to get the username + password of the user in the keychain of safari to fill fields in my web view form (I use the web shared credentials)

On My iPhone 14 (IOS 16.5) and simulator iPhone 12 (IOS 16.4) I call: `

    SecAddSharedWebCredential(domain as CFString, account as CFString, password as CFString) { error in
        if let error = error {
            print(error)
            return;
        }
        print("credentials saved")
    }

`

after this call, a popup appears which ask me to add/update/remove my log. All is working.

But on an other iPhone, there is always an error.

the error returns:

item: Mon compte
Error Domain=NSOSStatusErrorDomain Code=-25299 "Item already exists
for this server" UserInfo={number0fErrorsDeep=0, NSDescription=Item already exists for this server}
item: Déconnexion

I don't know why the error is "Item already exists for this server" because this method update de password if the username already exists. Also, there this error when I try to delete the item in the keychain passing the password to NULL (nil)

Do you know why this error is showing ?

Replies

It’s ok, I’ve found the the problem.