react-native-keychain: iOS 15 setInternetCredentials throwing "The user name or passphrase you entered is not correct" error

Since updating to iOS 15, it seems as if the setInternetCredentials method seems to be throwing an error: Error: The user name or passphrase you entered is not correct. at Object.promiseMethodWrapper [as setInternetCredentialsForServer]

I can understand this error in the context of getInternetCredentials however I am unsure how the username or password could be incorrect when setting a new credential in the keychain.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 31
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Following up on this since my last post. The issue remains for Simulators and devices(personal iPhone 12 mini) running iOS > 15. After doing some general digging posts it seems like the root issue is coming from Apple-land and is still ongoing. Reposting this Apple Developer Forum Issue is hidden amongst the other mentioned issues above and it seems fairly active. Hopefully, it can provide a little more context knowing that we’re not alone and the issue is bigger than react-native-keychain.

Sorry, I’m not able to provide any solid workaround or fix for the issue. Simply trying to share some details to prevent future rabbit holes.

Quick Update to my prior comment:

It seems like the recently released iOS version 15.3.1 may have resolved the issue for us. My team and our AB testing group updated our personal devices and simulators and we haven’t been able to replicate the issue. We didn’t update any code locally or update any other packages that would’ve patched this issue.

If you have tried updating your devices and simulators yet you might want to give that a try! I’m sorry if this doesn’t work for everyone, but I wanted to make sure I updated the thread.

setGenericPassword still does not work for me after updating to iOS version 15.4 in simulators.

Keychain.setGenericPassword('user', 'pass', { accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE, accessible: Keychain.ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY, })

It does seem to work on actual devices though.

If I remove accessControl from the options, it also works, but that is not very useful.

Does anyone have a solution to this problem?

Hey @jodavaga, which key in the options object is the one that controls the behaviour you suggested accessControl or accessible? I’ve been playing with the options today and the strange behaviour is that if I remove accessControl key it does not work on android but it works on iOS, so as a temporary solution I’m using:

    return Keychain.setGenericPassword(userName, secretValue, {
      service: bundleId,
      accessControl: Platform.OS === "android" ? ACCESS_CONTROL.BIOMETRY_ANY : undefined,
      accessible: ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
    });

This issue is only present on the simulator on real device works fine

Was having the same issue when trying to setGenericPassword, my code was:

      const result = await Keychain.setGenericPassword(
        userName,
        ENV.SECRET_VALUE,
        {
          service: serviceName,
          accessControl: ACCESS_CONTROL.BIOMETRY_ANY,
          accessible: ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
        }
      );

then I removed the options object and it started working

      const result = await Keychain.setGenericPassword(
        userName,
        ENV.SECRET_VALUE
      );

Any news on this issue?

Facing the same issue, downgrading iOS simulators to iOS 14 does still work. Updated react-native-keychain version urgently needed.

I’m hitting the same issue/error since my Xcode version updated the simulators to iOS 15 except I’m using setGenericPassword. Seems like something Apple did something silly.