sudo spctl –master-disable
Because of security reasons pressing the Allow button won’t take effect if you are connecting to the machine via Remote Desktop, or if the mouse/trackpad is emulated by a 3rd party application (MagicPrefs, BetterTouchTool, Synergy, etc.)
I have a third party app MagicPrefs. Which allows some additional controls to my mouse gestures, I had to disable this in order for the system to recognize the click on the allow button.
This was it! Clicking “Allow” over Screen Sharing doesn’t work so I pulled out Script Editor and
tell application "System Events" to click at {890, 460}
Point values may of course vary. Find them by taking a screenshot, opening it in Preview and doing a selection from the upper left corner to the button.