ASAuthorizationControllerDelegate prematurely considers authorization complete.

I've been using ASAuthorizationController and ASAuthorizationSecurityKeyPublicKeyCredentialProvider to add security key support to our app. The general flow is:

  1. ASAuthorizationController calls performRequest and brings up Apple's UI that prompts the user to use a security key.
  2. ASAuthorizationController calls a completion handler (either didCompleteWithAuthorization or didCompleteWithError) to indicate to the delegate that authorization is complete.

We should be able to immediately start another authorization request after the completion handler is called, but instead I get this error:

Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1004 "Request already in progress for specified application identifier." UserInfo={NSLocalizedFailureReason=Request already in progress for specified application identifier.}

Adding a 10ms or 100ms delay (testing on an iPhone 11 and running Xcode 14 on M1 Mac) after the completion handler still throws this error. Adding a 1s delay resolves the issue. The error makes me think that the UI prompting for user action is running async to the authorization logic and isn't fully dismissed when the completion handler is called.

Is there a better way to fix this issue that doesn't involve adding a delay?

Replies

Can you file this through Feedback Assistant and share your feedback number here, so that we can take a look? 🙂 Please include a screen recording and sysdiagnose, and the relevant code if possible.

Add a Comment

Thanks, the feedback number is FB11967949.