Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script fails to run in MacOS crontab. #200

Open
Shu-Ji opened this issue Dec 5, 2023 · 3 comments
Open

Script fails to run in MacOS crontab. #200

Shu-Ji opened this issue Dec 5, 2023 · 3 comments

Comments

@Shu-Ji
Copy link

Shu-Ji commented Dec 5, 2023

Everything is OK, if I manual run in the iterm.

Chrome 119.0.6045.199 (arm64)
MacOS Sonama 14.1.2

But when I add the script in crontab, it fails with the errors:

* * * * * /Users/xxx/.virtualenvs/scripts/bin/python -u /Users/xxx/.virtualenvs/scripts/scripts/cron/xxx.py >> /tmp/xxx.log 2>&1
Traceback (most recent call last):
  File "/Users/xxx/.virtualenvs/scripts/lib/python3.11/site-packages/browser_cookie3/__init__.py", line 580, in _decrypt
    decrypted = unpad(cipher.decrypt(
                ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/.virtualenvs/scripts/lib/python3.11/site-packages/Cryptodome/Util/Padding.py", line 92, in unpad
    raise ValueError("Padding is incorrect.")
ValueError: Padding is incorrect.
Traceback (most recent call last):
  File "/Users/xxx/.virtualenvs/scripts/scripts/cron/xxx.py", line 5, in <module>
    from browser_session import get, post
  File "/Users/xxx/.virtualenvs/scripts/scripts/cron/yyy.py", line 5, in <module>
    s.cookies = browser_cookie3.chrome()
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/.virtualenvs/scripts/lib/python3.11/site-packages/browser_cookie3/__init__.py", line 1161, in chrome
    return Chrome(cookie_file, domain_name, key_file).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/.virtualenvs/scripts/lib/python3.11/site-packages/browser_cookie3/__init__.py", line 515, in load
    value = self._decrypt(value, enc_value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/xxx/.virtualenvs/scripts/lib/python3.11/site-packages/browser_cookie3/__init__.py", line 586, in _decrypt
    raise BrowserCookieError('Unable to get key for cookie decryption')
browser_cookie3.BrowserCookieError: Unable to get key for cookie decryption

If I change to Safary:

PermissionError: [Errno 1] Operation not permitted: '/Users/xxx/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies'
@iamyifan
Copy link

Same issue when I'm using Safari on macOS and it shows PermissionError.
I can't even manually sudo cd to the cookie path .../Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies.

@hl105
Copy link

hl105 commented Jul 19, 2024

running into the same problem, have you found any solutions?

@Shu-Ji
Copy link
Author

Shu-Ji commented Jul 26, 2024

running into the same problem, have you found any solutions?

no,I switch to use nodejs/playwright now 💔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants