iOS13 (beta) Apple Login error
@available(iOS 13.0, *)
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error)
In my case, launching ASAuthorizationController
including a request for ASAuthorizationPasswordProvider
was causing the error.
Failed to complete operation. (com.apple.AuthenticationServices.AuthorizationError error 1000.)
From the ASAuthorizationError.Code documentation; 1000
is for unknown
ASAuthorizationError.Code.unknown
The authorization attempt failed for an unknown reason.
Declaration
case unknown = 1000
Ref: https://developer.apple.com/documentation/authenticationservices/asauthorizationerror/code/unknown
Now that's not particularly helpful but did give me a clue to check my ASAuthorizationController
setup which I was trying to launch with 2 requests from ASAuthorizationAppleIDProvider
& ASAuthorizationPasswordProvider
, like so:
func loginWithAppleButtonPressed() {
let appleSignInRequest = ASAuthorizationAppleIDProvider().createRequest()
appleSignInRequest.requestedScopes = [.fullName, .email]
let anySignInRequest = ASAuthorizationPasswordProvider().createRequest()
let controller = ASAuthorizationController(authorizationRequests: [appleSignInRequest,
anySignInRequest])
controller.delegate = self
controller.presentationContextProvider = self
controller.performRequests()
}
I tried this on a simulator that had an Apple ID with 2FA enabled and also on a device with another Apple ID without 2FA, and both times it would just go to authorizationController(controller:didCompleteWithError error:)
and that's it.
So to keep it simple, I launched ASAuthorizationController
with only ASAuthorizationAppleIDProvider
like so:
func loginWithAppleButtonPressed() {
let appleSignInRequest = ASAuthorizationAppleIDProvider().createRequest()
appleSignInRequest.requestedScopes = [.fullName, .email]
let controller = ASAuthorizationController(authorizationRequests: [appleSignInRequest])
controller.delegate = self
controller.presentationContextProvider = self
controller.performRequests()
}
And voilà! This time things worked as expected:
authorizationController(controller:didCompleteWithError error:)
with error 1000
So seems that in my case ASAuthorizationPasswordProvider
was the culprit but since ASAuthorizationError.Code.unknown
is a generic error case, this solution may not work for you.
Also, In my case I need only ASAuthorizationAppleIDProvider
for Apple ID sign in so dropped the support for ASAuthorizationPasswordProvider
.