Mojave: not authorized to send Apple events
If you’re suffering from error messages like the one above after upgrading to Mojave, welcome to macOS’s new “User Data Protections”. In this post we’ll explain what they are and how to deal with them.
That error’s produced when the app your script is targeting (in this example, System Events) has been denied access to one of the areas now protected in Mojave.
Here’s the list of places which are no longer accessible programmatically without user approval on 10.14:
If the app you’re targeting in your script – or the script runner itself – is trying to access any of those 12 locations, you’ll likely either get the error shown at the top of this post, or some other failure.
The official way of dealing with this is to add the application to System Preferences’ new ‘Full Disk Access’ section in the Privacy pane:
At least that’s the theory, but you might find that you’ve tried that and things are still not working. If that happens, you can “start over from scratch” by resetting the access permissions to default.
In Terminal, try
tccutil reset AppleEvents; tccutil reset SystemPolicyAllFiles
After you’ve done that, the next time you run that script you should get an authorization dialog like this:
Alternatively, just go right ahead and add the app with the ‘+’ button in System Preferences.
Enjoy the resumption of normal service 🙂