Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Unable to run AppleScript from osascript : not authorized to send Apple Events

I have written a script that interacts with the calendar application. It works fine when run from the Script Editor, but when I try to run it from the command line using osascript, I get this error:


collect_events.scpt: execution error: Not authorized to send Apple events to Calendar. (-1743)


Unfortunately, AFAICT there is no way to fix this problem. There is no way to add Calendar to the set of applications that osascript is allowed to control:


So what should I do?


I see a number of different questions that are similar to this one in the discussions, and I don't see any solution, so does that mean this is impossible?


I thought it might be possible to work this by saving my script as an application. Indeed, this does get me an entry in the options:


but now when I run my application it pops up an access authorization dialog box like this:

...and when I click "OK," it pops up the same window again, and again, and again, and ...


Posted on Sep 12, 2022 4:43 PM

Reply
Question marked as Best reply

Posted on Sep 14, 2022 1:46 PM

Thanks. I got the problem fixed by ... turning it off and turning it on again!


Once I rebooted, then `osascript` worked fine with my script.


As an aside, there's a bit of a vocabulary problem here. The error message talks about my script not being able to send "Apple Events," but the Security and Privacy tab talks about "System Events." I think they are the same thing, but it's not at all clear....

Similar questions

2 replies
Question marked as Best reply

Sep 14, 2022 1:46 PM in response to etresoft

Thanks. I got the problem fixed by ... turning it off and turning it on again!


Once I rebooted, then `osascript` worked fine with my script.


As an aside, there's a bit of a vocabulary problem here. The error message talks about my script not being able to send "Apple Events," but the Security and Privacy tab talks about "System Events." I think they are the same thing, but it's not at all clear....

Sep 12, 2022 4:57 PM in response to rpg25

Calendar can always receive events. If there is a permissions problem, it is on the sending side.


Can you provide more details about what your script does (i.e. the script itself) and how you are running it?


I tried a little demo using just:


tell application "Calendar"
	activate
end tell


and running it with:


osascript testing.scpt


It works fine

Unable to run AppleScript from osascript : not authorized to send Apple Events

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.