Not authorized to send Apple events to Music

Hello all,
I’m writing a simple Music controller app using ApplescriptObjC in Xcode but when I click a button to play/pause the music I get “-[AppDelegate playPause:]: Not authorized to send Apple events to Music. (error -1743)”. I understand that this is macOS’s privacy settings kicking in and that I need to enable the usage description, but the thing is I already put the “Privacy - Media Library Usage Description” in info.plist and it’s still not working. Any help would be greatly appreciated.

Here is the handler thats throwing the error, just in case there’s something wrong with it.

on playPause_(sender)
             tell app "Music" to playpause
    end playPause_

You have to add the “Privacy - AppleEvents Sending Usage Description” key

Thank you for your response. I added the key but the same error is still occurring.

Is Hardened Runtime enabled in Signing & Capabilities? If yes, you have to check also the Apple Events checkbox

That worked! Thank you so much for your help.

Hi
I’m having a similar problem, “Not authorized to send Apple events to Contacts. (error -1743)” when trying to add a new contact to Contacts using ApplescriptObjC project.
Found your original post and solution, have set Hardened Runtime to Yes but don’t know where to find Apple Events checkbox, please can you advise me.
Many thanks

“Privacy - AppleEvents Sending Usage Description” is a key in Info.plist

Thank you for your rapid response, added the Privacy - AppleEvents Sending Usage Description and set Enable Hardened Runtime to Yes but still issues message “Not authorized to send Apple events to Contacts. (error -1743)”.
Is there anything I have to add to the coding in the app?
Thanks in advance.