Cookie extraction stopped working on Chrome 130 (Mac OS)
I have been using browsercookie in a custom script to fetch API values (for months), but it seems the latest version of Chrome changed something and bc is not able to extract cookies anymore.
Chrome version: Version 130.0.6723.92 (Official Build) (arm64) - Mac OS Sonoma 14.7.1 (23H222)
Traceback (most recent call last):
File "scripts/script.py", line 98, in cookie_extract
cj = browsercookie.chrome()
^^^^^^^^^^^^^^^^^^^^^^
File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 540, in chrome
return Chrome(cookie_files).load()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 99, in load
for cookie in sorted(self.get_cookies(), key=lambda cookie: cookie.expires):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 168, in get_cookies
value = self._decrypt(item[5], item[6], item[4], item[1], key=key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 195, in _decrypt
return clean(decrypted)
^^^^^^^^^^^^^^^^
File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 188, in clean
return x[:-last].decode('utf8')
^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 1: invalid start byte
I tried to delete cookies a few times and got different values for the hex value of the byte in position 1.
Please note that the same script still works perfectly under Firefox, whereas using Safari the script does not throw an error and just exits back to the shell.
same problem on me,check https://github.com/borisbabic/browser_cookie3/issues/214 and https://github.com/borisbabic/browser_cookie3/issues/210
it may help
Thanks I tried the patched branch, now it won't die with an error anymore, but still the cookies I need are missing (actually the entire domain is gone).
For now I'll stick to using Firefox instead of Chrome.