Not authorized to send Apple events to Contacts. (-1743)

As I posted in a Topic on launchd:

Looking at this Topic lead me to believe that I need to reset the privacy database using tccutil. Indeed, my application is not listed in the Privacy tab of  → System PreferencesSecurity & Privacy:

I reviewed A Guide to Catalina’s Privacy Protection and How-to: Reset Privacy Permissions in macOS, downloaded Taccy to figure out my application’s name, and gave terminal a try:

Unfortunately, I get the same error when I double click on my application and the Privacy tab is unchanged. No, when I launch my application I do NOT get a dialog box asking for permission to access Contacts.

How do I fix this error?

It seems like I run the applet, get the error and immediately go to System Preferences >Security and Privacy>Privacy and scroll to the category (ie Contacts), the app name is there with an empty checkmark.

Not sure why that’s not happening, unless, when you got the error there was an option to deny permission and you clicked that?

Yes, I should be looking for my application in the category Contacts, not Automation as I show above. It’s not there either.

I don’t recall every denying permission.

But, even if I did, shouldn’t the tccutil reset… make it prompt me again?

I tried a few variations on tccutil reset…

First, I tried it with sudo:

    Argus-2:~ nello$ sudo tccutil reset AddressBook com.mycompany.Birthday-Message-ver-5
    Successfully reset AddressBook approval status for com.mycompany.Birthday-Message-ver-5
    Argus-2:~ nello$ 

Still got the same error.

Then I tried resetting privacy for all applications requesting access to Contacts:

Argus-2:~ nello$ tccutil reset AddressBook
Successfully reset AddressBook
Argus-2:~ nello$ 

As expected, this access to Contacts for all applications:

I ran my script within Script Debugger, was prompted for permission to access Contacts, authorized access, and the authorization appears in the Privacy tab:

Then I tried double clicking on my applet; I was NOT prompted for permission and access was denied:
Screen Shot 2022-06-10 at 1.53.54 PM

Then I noticed that (Script Debugger?) had auto-saved my script:

So, I double clicked on the Autosaved file, and I got these TWO dialogs to allow permission, which I did:

And lo and behold, the auto-saved applet appears in the Privacy tab now:

When I double click on the original applet and I still get the error.

When I double click on the Autosaved applet, it runs. :partying_face:

Then saved the the script using Save As… using the format Application (Apple) and it replaced the Autosaved applet file.

When I double click on the Save As… applet, it the same two dialogs appear asking for permission to access Contacts and when I approve both, the applet runs perfectly.

So, I don’t know what it was, but apparently there was something wrong with the first applet that I saved.

The only thing difference that I can think of is that I renamed the original applet (in the Finder) after saving it. Is the applet’s file name somehow tied to permissions? I had assumed that the permissions are tied to the value of CFBundleIdentifier in the applet’s Info.plist.

So, I renamed the Save As… applet’s file name and it still runs perfectly without asking for permission. But interestingly, the new file name has been added to the Privacy tab withOUT asking permission first:

But look closer. I put the Save As… applet in the trash and notice that it’s been removed from the tab (without emptying the trash). And also, see that the original applet now appears in the tab! But, when I double click on it I still get the same error.

Finally, I’m surprised to see that renaming the applet in the Finder causes the name of the script in Script Debugger to change too:

Anyway, for some reason that first applet wouldn’t trigger a request for permission to access Contacts and so it couldn’t run.

But all the subsequent applets are requesting permission as expected and running perfectly.

All’s well that ends well? :thinking: