ASWebAuthenticationSession won't open the Safari login window on Monterey

My macOS app uses ASWebAuthenticationSession for users to login to a third party service. It's worked fine until Monterey.

When I call start on ASWebAuthenticationSession it shows me the permission window as expected:

However when I click Continue nothing else happens. It does not show the Safari window and load the login page.

I've noticed these errors appear in the Console every time, so it seems it's having trouble opening Safari (even though I have Safari already open).

Any suggestions on how to fix this? Surely ASWebAuthenticationSession isn't broken for everyone?

error	10:40:50.598301+0000	kernel	43 duplicate reports for Sandbox: com.apple.WebKit(13346) deny(1) mach-lookup com.apple.diagnosticd
error	10:40:50.598309+0000	kernel	Sandbox: SafariLaunchAgen(5469) deny(1) system-fsctl _IO('h', 47)
error	10:40:52.349729+0000	kernel	Sandbox: com.apple.WebKit(6675) deny(1) mach-lookup com.apple.diagnosticd
error	10:40:53.011948+0000	CoreServicesUIAgent	LAUNCH: Launch failure with -10652/ <FSNode 0x60000068b6e0> { isDir = y, path = '/Applications/Safari.app' }
error	10:40:53.019505+0000	CoreServicesUIAgent	Unable to forward entitlements from overridden keySenderAuditTokenAttr [sess=100005 pid=5469 uid:501,501,501 g:20,20 pV:257536] to target port ( port:85539/0x14e23 rcv:0,send:2,d:0 limit:0), which will likely cause them to reject this AppleEvent, errorRef=[ NULL ]
Answered by Systems Engineer in 716453022

This issue was fixed in macOS 12.4. If you see further issues, please file additional feedbacks 🙂.

I’m still getting this issue on macOS 12.4. When I press ‘Continue’, this gets logged in Console:

20:41:59.415416+1000	error	kernel	<Missing Description>	Sandbox: com.apple.WebKit(30034) deny(1) mach-lookup com.apple.diagnosticd
20:42:00.553550+1000	error	kernel	<Missing Description>	35 duplicate reports for Sandbox: com.apple.WebKit(30034) deny(1) mach-lookup com.apple.diagnosticd
20:42:00.553559+1000	error	kernel	<Missing Description>	Sandbox: SafariLaunchAgen(66809) deny(1) system-fsctl _IO('h', 47)

The alert also doesn’t go away, even when I click ‘Continue’ or ‘Cancel’. I have to pkill UserNotificationCenter to get rid of it.

ASWebAuthenticationSession won't open the Safari login window on Monterey
 
 
Q