How to enable Touch ID in prompt for password using Applescript in Objective C

1.1k Views Asked by At

I am using a solution from @CarlosP in my objective C app to execute a script as administrator.

Link is above but basically it's doing this:

NSDictionary *errorInfo = [NSDictionary new];
NSString *script =  [NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", fullScript];

NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
NSAppleEventDescriptor * eventResult = [appleScript executeAndReturnError:&errorInfo];

It works great, but it doesn't enable/allow Touch ID. Is there a way for me to do that within the scope of NSAppleScript?

1

There are 1 best solutions below

2
Sers On

You can enable Touch ID authorization for sudo. Check details here and here.

Add auth sufficient pam_tid.so to /etc/pam.d/sudo file. In you Applescript remove with administrator privileges and use sudo in your shell script.