macOS Mojave, Automator “Not authorized to send Apple events to System Events.”

This is definitely a part of Mojave's new security framework. In terminal try

osascript -e 'tell application "Finder"' -e 'set _b to bounds of window of desktop' -e 'end tell'

and you may receive:

36:42: execution error: Not authorized to send Apple events to Finder. (-1743)

What is supposed to happen on the first execution is the Finder opens a dialog box informing you that terminal is requesting permission to send events to the Finder. If you allow it, then terminal will get added to the Automation page in System Preferences > Security & Privacy > Automation:

enter image description here

There's two issues that I see at the moment:

  • the implementation of requesting permission for the scripting action appears to be bugged; I've run other scripts that request permission to send events to Safari and the Finder doesn't prompt for permission, it just returns an error.
  • streamlined automation requires some type of mechanism to have the permissions granted a priori; an example would be utilizing AppleScript with Ansible and being unable to preload grants

Others have written up more extensive information about this:

  • https://www.felix-schwarz.org/blog/2018/06/apple-event-sandboxing-in-macos-mojave
  • https://forums.developer.apple.com/thread/106949

Hopefully this gets worked out before Mojave ships as it seriously impacts automation capabilities on macOS.


I have solved the same issue using the below steps. Open Plist and add the below keys in it

<key>NSAppleEventsUsageDescription</key>
<string>Please give access to Export details to Outlook</string>

You will get a confirmation pop up to allow or disallow when your application starts executes the script first time. if you click allow, it will execute the script.


I had a similar error running AppleScript .app applications. I received the following error:

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

A workaround is to export (File > Export) or save (File > Save As, holding Option key to show Save As) a new Application from the .scpt or .applescript source code. This generates a new .app application, which in my case ran successfully. The initial launch required approval (as well as some subsequent launches), and the application was added as an entry under Settings -> Security & Privacy -> Privacy -> Automation.


I faced same error opening gitk.

Error in startup script: execution error: Not authorised to send Apple events to System Events. (-1743)


SOLUTION

Goto Settings -> Security & Privacy -> Privacy -> Automation -> Privacy tab and check the System Events checkbox.

enter image description here