Sub topic 14
Controlling which apps can see your data
macOS treats your mail, calendars, and contacts as protected data. An app cannot read them just because it runs under your user account. This chapter explains how that protection works, how to review and change it, and which errors appear when access is missing. It also covers how this affects the automation scripts from the last chapter of this tutorial.
You should already know how to add accounts in System Settings and how Mail, Calendar, and Contacts store data from those accounts. You should also be comfortable opening System Settings and using Terminal.
What is protected and why
Mail, Calendar, and Contacts hold some of the most personal information on your Mac. They include your correspondence, your schedule, and the names and numbers of people you know. Because of this, macOS uses a system called TCC (Transparency, Consent, and Control). TCC keeps a record of which app has been allowed to reach which kind of data.
The idea is simple. The first time an app asks for protected data, macOS shows a prompt. You choose Allow or Don't Allow. macOS stores your answer and applies it every time after that, until you change it.
Three points are worth knowing from the start:
- The permission belongs to the app that asks, not to the data. Contacts has one list of people, but each app that wants to read it needs its own approval.
- A permission is a setting about one kind of data. Allowing an app to see Contacts says nothing about Calendar.
- The built-in Mail, Calendar, and Contacts apps do not need approval to read their own data. Permissions matter for other programs that want to reach it.
Where the settings live
Open System Settings and choose Privacy & Security. The list contains one entry for each kind of protected data. The three that matter here are:
| Entry | What it controls |
|---|---|
| Contacts | Apps that may read and change your contact cards |
| Calendars | Apps that may read and change events |
| Reminders | Apps that may read and change reminders, which Calendar-compatible apps often use as well |
| Full Disk Access | Apps that may read protected files anywhere on disk, including Mail's data folder |
| Automation | Apps that may send commands to other apps |
Click an entry to see a list of apps with switches. A switch that is on means the app is allowed. Turning it off removes access at once. The app is not told why. It simply starts receiving an error or empty results.
Newer versions of macOS split Calendars into more detailed choices, such as full access versus add-only access. If you see such options, choose the narrowest one that lets the app do its job. An app that only adds events does not need to read your whole schedule.
Mail is a special case
Mail does not appear in the same simple way as Contacts and Calendars. Mail keeps messages as files in your Library folder, and macOS protects that folder. So an app or script that tries to read Mail's files directly gets blocked, even if it has no interest in Calendar or Contacts.
Apps use one of two routes to get at mail:
- Ask the Mail app through automation. This is the safer route, because Mail decides what to hand over.
- Read the files directly. This requires Full Disk Access, which is much broader.
Prefer the first route. Full Disk Access lets an app read nearly everything you own, so grant it only to software you trust fully, such as a backup tool you chose on purpose.
The Automation permission
The Automation list controls something different from the data lists. It records which app may control which other app. An entry looks like "Terminal can control Mail". Under Terminal, you may see switches for Mail, Calendar, and Contacts.
The first time a script tells another app what to do, macOS asks you to approve that link. Try this script in Terminal, using the osascript command, to see the prompt:
tell application "Mail"
get name of every account
end tellSave it as accounts.applescript and run it with osascript accounts.applescript. If you approve, you get a list of account names. If you decline, the command fails.
Approval is per pair. Allowing Terminal to control Mail does not let it control Calendar. Likewise, if you run the same script from a different program, such as a script editor or a launcher tool, that program needs its own approval.
How a request is decided
The following diagram shows what happens when an app asks for protected data.
The saved answer is the key step. A prompt appears only once. If you declined by accident, no second prompt appears later, and you must fix it in System Settings or by resetting the record.
Recognizing a permission problem
A missing permission rarely looks like a permission problem. Common signs include:
- A script returns an empty list when you know data exists.
- A script fails with an error such as "Not authorized to send Apple events to Mail" (error number -1743).
- An app that reads your calendar shows no events, even though Calendar itself shows them.
- A tool that reads Mail's folder reports "Operation not permitted".
When you see one of these, check Privacy & Security before you suspect the account or the network. Compare the app's name against the relevant list and make sure the switch is on.
If the app is missing from the list altogether, it has never asked, or you reset its record. Run the action again so that the prompt can appear.
Resetting a saved answer
Sometimes an app is not listed, or you want to see the prompt again. The tccutil command clears saved answers for one kind of data. This command resets Calendar permissions for every app:
tccutil reset CalendarYou can limit the reset to one app by adding its bundle identifier, which is a unique name for the app. For Terminal that name is com.apple.Terminal:
tccutil reset AppleEvents com.apple.TerminalHere AppleEvents is the category used for the Automation list. Other category names include Calendar, AddressBook (the name used for Contacts), and SystemPolicyAllFiles (Full Disk Access).
Good habits for granting access
- Read the prompt. It names the app and the data type. If a tool you just installed asks for Contacts and has no reason to, choose Don't Allow.
- Review each list every few months. Remove apps you no longer use.
- Avoid Full Disk Access unless there is no alternative.
- Keep in mind that a granted app can read everything in that category, including data from every account. You cannot allow an app to see only your iCloud contacts and not your Exchange ones.
Permissions and the automation scripts
The scripts in the previous topic, such as listing calendar names or contact groups, only work once the right permission exists. When a script is run from Terminal, the approval is recorded for Terminal. When it runs from a scheduled task, the approval belongs to whichever program starts it. Test a new script by hand first, so that you can answer the prompts while you are watching.
Exercise
A script that lists calendar names works in Terminal and returns an empty result when started by a launcher app you installed last week. Calendar itself shows all your calendars. What is the most likely cause, and where do you fix it?
Show answer
The launcher app has no saved approval for Calendar or for controlling Calendar, while Terminal does. Permissions belong to the requesting app. Open System Settings, then Privacy & Security, and check the Calendars and Automation lists for the launcher. Turn its switch on. If it is not listed, run the script again so that the prompt appears, or run tccutil reset for that category and try again.
Exercise
Why is allowing an app to control Mail through Automation usually safer than giving it Full Disk Access to read Mail's files?
Show answer
With Automation, the Mail app decides what data to hand over, and the approval covers only the link between the two apps. Full Disk Access lets the app read nearly every protected file on the Mac, far beyond mail.