SecAddSharedWebCredential works in simulator, not device

I am trying to save the user name and password so users can use the Safari Auto Login for my app. Here is what I have:


SecAddSharedWebCredential(CFSTR("www.website.com"),
                                      (__bridge CFStringRef)(usernameField.text),
                                      (__bridge CFStringRef)(passwordField.text),
                                      ^(CFErrorRef error) {
                                          NSLog(@"%@", error);
                                      });


It works great on the simulator but on the device I get an error:

""www.website.com" failed to approve "uniquecode.com.website"


Any idea why it would work on one and not the other?


Thanks

I have this same problem right now, at one time it worked from my device (iPhone 7) but now it refuses to store or retrieve credentials.


I get an error back from SecAddSharedWebCredential:

Error Domain=NSOSStatusErrorDomain Code=-25293 ""[host]" failed to approve "[app ID]"" UserInfo={NSDescription="[host]" failed to approve "[app ID]"}

I can assure you that [host] does host /apple-app-site-association and that [app ID] is correctly specified in that file.


Again this works just fine from the simulator. I've deleted all my keychain logins for this and any associated hosts, yet it persists as a problem.


Even if I set the credentials via Safari (by signing in at [host] and saving my credentials on login) it will still return an error of the same nature from SecRequestSharedWebCredential

EDIT:

A thought occurred to me that this may be cert related. Our test env host doesn't have a particularly valid SSL cert, but it does serve SSL if you agree to accept this invalid cert... so I'm guessing the sims don't much care, but my actual device does.

Hey Chris,

Have you succeeded to solve the issue on your side? I am facing the same one right now and am just clueless how to make it work on a real device.

I have facing exactly same issue working fine in simulator but not working in device, I recognized my TeamID and Prefix ID was different I changed my team ID to prefix and update apple assocaition file but still same issue.

Had such issue. I had email text field and tried to save email and generated password to shared Credentials. Also was getting -25293 only for real devices.

Fixed by adding such code before SecAddSharedWebCredential call:


if #available(iOS 11.0, *) {

EmailTextfield.textContentType = .username


let passwordTextfield = UITextField.init()

passwordTextfield.textContentType = .password

}


After code adding error gone

Hello, I have also faced precisely the same issue, working fine in the simulator but not working in the device. Anyone has found any solution? please reply.

SecAddSharedWebCredential works in simulator, not device
 
 
Q