Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASAuthorizationController fails with existing setup flows

Apple's examples said to perform authorization attempt as soon as the login view appears using the code shown below. When the code runs I get this non-helpful error:

[core] Authorization failed: Error Domain=AKAuthenticationError Code=-7001 "(null)" UserInfo={AKClientBundleID=com.....SignInWithApple}

I do have something stored in the shared web credentials that it could be grabbing. Here's the code I'm using:

private func performExistingAccountSetupFlows() {   
  let requests = [
    ASAuthorizationAppleIDProvider().createRequest(),
    ASAuthorizationPasswordProvider().createRequest()
  ]

  appleSignInDelegates = SignInWithAppleDelegates(window: window)

  let controller = ASAuthorizationController(authorizationRequests: requests)
  controller.delegate = appleSignInDelegates
  controller.presentationContextProvider = appleSignInDelegates

  controller.performRequests()
}

Have I missed a step here?

like image 596
Gargoyle Avatar asked Aug 01 '19 05:08

Gargoyle


2 Answers

You can't run this code on a simulator. That's what the error is saying, even though it doesn't actually say that. If you run on a device it works properly.

So just wrap the code in an #if !targetEnvironment(simulator)

like image 180
Gargoyle Avatar answered Nov 18 '22 12:11

Gargoyle


Try this: 1) Tap on the Apple Sign In button 2) Swipe up (lightly just so the App doesn't switch) the white bar on the bottom of the screen.

The pop up seem to be stuck sometimes, that's why doesn't show and this error logs.

It's weird right now.

like image 28
TDesign Avatar answered Nov 18 '22 14:11

TDesign