ASAuthorizationPasswordProvider on macOS

Does ASAuthorizationPasswordProvider work on macOS? I've watched WWDC 2019 session 516 and I'm using the code that's presented there, but I can't get it to work on macOS. The same code works fine on iOS. It's not clear from the video if this is supported in AppKit apps, or if it's only for Catalyst apps.


This is my code:


let authController = ASAuthorizationController(authorizationRequests: [
    ASAuthorizationPasswordProvider().createRequest()
])
authController.delegate = self
authController.presentationContextProvider = self
authController.performRequests()


I get this message when I run it on macOS:


[core] Authorization failed: Error Domain=AKAuthenticationError Code=-7089 "(null)"


The error in the ASAuthorizationControllerDelegate is


Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1000 "(null)"


My bundle id, entitlements and server are configured correctly.


Thanks,

Steven

Have you implemented a presentation anchor in the ASAuthorizationControllerPresentationContextProviding delegate? You'll need to return a window for the ASAuthorizationPasswordProvider to display from.


Here's an example code snippet

func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
        return self.view.window!
}


Also, please note that your app must have a domain associated with it via the Associated Domains entitlement and an existing credential for that domain stored in the keychain. You can learn more about Supporting Associated Domains in Your App

Yes, I've implemented that method. I've also set up the associated domain entitlement and included the apple-app-site-association file on my server. I'm quite sure that this part of the setup is correct, since the same setup works on iOS. My Keychain has several credentials in it for my domain.

ASAuthorizationPasswordProvider on macOS
 
 
Q