Skip to content

How to get access to Reminders in anything else than Terminal聽#68

Open

Description

@Zjaaspoer

First of all @keith, great tool, works flawlessly! 馃檹

The only caveat is that it only work directly in Terminal. If it's being called from any other application you get the "You need to grant reminders access" error generated by the app.

I've looked at #58 (it was solved through Apple Script: is too hacky for my purpose), #13 but that discussion is stale, #4 is related but too much on a programmatic level.

My request is that this app is usable by other apps than the terminal.

My assumption is that the code

`public static func requestAccess() -> Bool {
let semaphore = DispatchSemaphore(value: 0)
var grantedAccess = false
Store.requestAccess(to: .reminder) { granted, _ in
grantedAccess = granted
semaphore.signal()
}

    semaphore.wait()
    return grantedAccess
}

`

works in the terminal and indeed requests access to Reminders, which you can later see here:
image

Maybe the code can be improved to work also when being called by other apps, and in this way asks permission to the user to grant the current app permission to access Reminders, so it will show up in the list above.

(Not a Swift programmer so there are some big assumptions I made 馃槄)

Thanks again for your great work 馃挭

Activity

  1. keith commented on Aug 29, 2023

    @keith
    Owner

    thanks for the kinda words. i don't think there is anything we can do here, you'll probably just have to manually add it there if the popup doesn't happen

  2. Zjaaspoer commented on Aug 30, 2023

    @Zjaaspoer
    Author

    Hi @keith, apologies for cropping the screenshot too much, but in the full view you'll see you can't add apps manually:

    image

    (no plus in the

    Compared to e.g. Full Disk Access where you can add app by using the plus in the bottom left

    image

    Non of the apps outside of terminal trigger asking for access permission

  3. keith commented on Aug 30, 2023

    @keith
    Owner

    oh bummer. afaict there's no alternative API for us to be calling https://developer.apple.com/documentation/eventkit/ekeventstore?language=objc

  4. Zjaaspoer commented on Aug 30, 2023

    @Zjaaspoer
    Author

    Ok got it. Not an area I'm familiar with so unfortunately not something I can help with. Thanks for thinking along!

  5. keith commented on Aug 30, 2023

    @keith
    Owner

    I think it's up to macOS to prompt for this stuff so I'm not sure why it doesn't in some cases. Maybe when we ask and it fails the app appears there but disabled?

  6. Zjaaspoer commented on Aug 31, 2023

    @Zjaaspoer
    Author

    So I tried in in different app, e.g. Visual Studio Code. It fails without showing a prompt as discussed, but then doesn't how up in the MacOS settings (shown above) unfortunately. It looks like the asking for permission in those apps is not working?

  7. keith commented on Nov 9, 2023

    @keith
    Owner

    What OS version were you on with this? I started seeing this with Sonoma and have a fix

  8. keith commented on Nov 9, 2023

    @keith
    Owner

    Fixed my case in #70, if 2.4.0 doesn't fix this for you please comment with the error that is now printed and we can try to find a fix.

  9. Zjaaspoer commented on Nov 9, 2023

    @Zjaaspoer
    Author

    Hey @keith, I'm on Sonoma too now:
    image

    Just tested again and these are the outcomes.

    I have the latest version
    image

    It works perfect if I use my terminal (in this iTerm)

    When I use any other program (in this case VSCode) it exits with your new error
    image

    I'm not prompted when running in VSCode to allow VSCode to access Reminders & in the privacy settings I still can't add any program manually
    image

  10. reopened this on Nov 9, 2023
  11. keith commented on Nov 9, 2023

    @keith
    Owner

    I guess the lack of an error in the second screenshot means There wasn't an actual error and it really is just a permissions issue.

  12. Zjaaspoer commented on Nov 9, 2023

    @Zjaaspoer
    Author

    Indeed, if I read the code correctly it looks like there is no error

  13. keith commented on Nov 9, 2023

    @keith
    Owner

    I tried this too and see the same. Previously https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard solved this, but it doesn't seem to help in this case. It must have something to do with how VSCode spawns its terminal

  14. rhsev commented on Apr 16, 2024

    @rhsev

    When I access the Mac via ssh (Sonoma) and call reminder-cli, I get the same error message.

  15. keith commented on May 12, 2024

    @keith
    Owner

    I tried debugging the ssh case a bit, the problem seems to be that the requesting process is the ssh tool. I tried codesigning the reminders-cli binary w/ the proper entitlements to see if that helped but it did not. If anyone finds a workaround for this type of case I'd love to hear it. To debug you can open Console.app, stream logs, and search for tccd. The failing lines in my case debugging ssh looked like this:

    default	19:58:08.244867-0700	tccd	AUTHREQ_ATTRIBUTION: msgID=3284.253, attribution={responsible={TCCDProcess: identifier=com.apple.sshd-keygen-wrapper, pid=10390, auid=501, euid=0, responsible_path=/usr/libexec/sshd-keygen-wrapper, binary_path=/usr/sbin/sshd}, accessing={TCCDProcess: identifier=com.smileykeith.reminders-cli, pid=13404, auid=501, euid=501, binary_path=/private/tmp/reminders}, requesting={TCCDProcess: identifier=com.apple.calaccessd, pid=3284, auid=501, euid=501, binary_path=/System/Library/PrivateFrameworks/CalendarDaemon.framework/Support/calaccessd}, },
    default	19:58:08.244894-0700	tccd	requestor: TCCDProcess: identifier=com.apple.calaccessd, pid=3284, auid=501, euid=501, binary_path=/System/Library/PrivateFrameworks/CalendarDaemon.framework/Support/calaccessd is checking access for accessor TCCDProcess: identifier=com.smileykeith.reminders-cli, pid=13404, auid=501, euid=501, binary_path=/private/tmp/reminders
    default	19:58:08.250096-0700	tccd	Policy disallows prompt for Sub:{/usr/libexec/sshd-keygen-wrapper}Resp:{TCCDProcess: identifier=com.apple.sshd-keygen-wrapper, pid=10390, auid=501, euid=0, responsible_path=/usr/libexec/sshd-keygen-wrapper, binary_path=/usr/sbin/sshd}; access to kTCCServiceReminders denied
    

    There are some unsupported ways around to try and add something to the tcc db from the command line but I haven't treid any of them https://forums.developer.apple.com/forums/thread/119373, it's possible that if you add whatever app you're launching reminders-cli from that it would start working. Let me know if you find any workarounds!

  16. aizerin commented on Aug 19, 2024

    @aizerin

    I have a similar problem but with launchctl. I have a scheduled job

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>Label</key>
            <string>com.test.todo-export</string>
            <key>StandardErrorPath</key>
            <string>/tmp/mycommand.err</string>
            <key>StandardOutPath</key>
            <string>/tmp/mycommand.out</string>
            <key>ProgramArguments</key>
            <array>
                    <string>sh /Users/asdf/reminders_sync.sh</string>
            </array>
            <key>StartInterval</key>
            <integer>1800</integer>
    </dict>
    </plist>
    

    with shell script reminders_sync.sh

    #!/bin/sh
    
    /opt/homebrew/bin/reminders show-all
    

    When I run it for test with launchctl start com.test.todo-export then it will always ask for permissions in every single run and show no data.

    It seems that reminder-cli app is added to the reminder permissions, so I have no idea why it is not working.

    image

    When I run same script from terminal then there is no problem.

  17. aizerin commented on Aug 19, 2024

    @aizerin

    I found a workaround. It seems that reminders-cli cannot use granted permissions (I don't know why). So I've created script in nodejs

    const { exec } = require('child_process');
    
    exec(`osascript -e 'tell application "Reminders" to show (first list whose name is "blabla")'`, (error, stdout, stderr) => {
        if (error) {
            console.error(`Error: ${error.message}`);
            return;
        }
        if (stderr) {
            console.error(`Stderr: ${stderr}`);
            return;
        }
        console.log(`Stdout: ${stdout}`);
    });
    

    which populate permission for current running application. For example if you run it in VSCode, then vscode will get Reminders permissions and then you can use reminders-cli directly from vscode ... 馃く

    To use it in launchctl just use this script for first time

    #!/bin/bash
    
    node /path/reminders_permissions.js
    

    then you can give permissions to nodejs executable

    image

    After that you will need to create wrapper around reminders-cli command in nodejs. For example

    const { spawn } = require("child_process");
    
    const runCommand = (command, args) => {
      const process = spawn(command, args);
    
      process.stdout.on("data", (data) => {
        const output = data.toString();
        console.log(output);
      });
    
      process.stderr.on("data", (data) => {
        console.error(`Stderr: ${data}`);
        exit(1);
      });
    };
    
    runCommand("/opt/homebrew/bin/reminders", [
      "show",
      "prace",
      "--format",
      "json",
    ]);
    

    and than you can use it in bash script which you will run from launchctl. for example

    #!/bin/bash
    
    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
    
    todos=`node /path/reminders_sync.js`
    
    curl -X POST -H "Content-Type: application/json" -d "$todos" http://dietpi.local:3010/api/todo
    

    馃帀馃帀馃帀馃帀馃帀馃帀
    馃く馃く馃く馃く馃く馃く

    btw: thanks for this tool 馃檹

  18. added a commit that references this issue on Oct 31, 2024
  19. mesveldt commented on Sep 6, 2026

    @mesveldt

    Kind of a stale thread, but I encountered this as well. Running bash -c reminders in kitty, instead of a direct invocation of reminders triggered the permissions prompt for kitty (macos 26.6.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions