-
Notifications
You must be signed in to change notification settings - Fork 145
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
Access to cookie file denied on chrome>104.0.5112.102 #180
Comments
Possible duplicate of #179. Having a look. |
Can't it be used anymore? |
same issue. began after latest chrome update. |
There will be issues with the latest version of Chrome, and if the version is rolled back to 104.0.5112.102, there will be no issues |
@zhaotong1121 @omineko1 Is the issue happing only on windows? I've checked on Linux, works fine there. |
I am on windows 64 bit and I rolled chrome back to 114.0.5735.110 to get it working again |
Can not reproduce :(. Need help. |
Win10 22H2 64bit [Version 10.0.19045.2965] with all updates installed. System has the only user account. |
Edition Windows 11 Pro It's not working on new Chrome version in windows. So I solved this issue temporarily by following the post. |
@jxchlee Confirmed it works, thanks for saving my day! |
Is that temp solution to use "--disable-features=LockProfileCookieDatabase" the only option still for windows? Not a ideal work around since default Chrome settings still don't allow the cookie reading functionality to work right. |
The This thread has some more context: yt-dlp/yt-dlp#7271 (comment). On that project, there's a new PR showing using Win32 ShadowCopy API that sounds like it works even when Cookies is locked, but requires the python process to be elevated... |
Windows 10 64 browser-cookie3 0.13.0 browser-cookie3 Unable to read cookie data from Chrome, it used to be normal。 |
Hey folks, I wrote that PR for yt-dlp.. and somehow found this thread. It uses ShadowCopy and works just fine when elevated. Another way of potentially getting cookies is to read off the disk directly. Basically you would find the NTFS info for the file (including offset) and then you would read it (and i guess have similar issues for other file systems). Unfortunately that needs elevation as well. I don't think there will be a way to get the locked file content without elevation on Windows unfortunately. TLDR: ShadowCopy seems like the best way at the moment, but requires elevation. |
@csm10495 Do you want to write a patch for this package too? I'll appreciate your contribution. |
I think best bet would be for me to take the logic i wrote in yt-dlp and move it out to a simple/small lib. Probably only one function: Then browser_cookie3 would be able to import it. I'm a bit nervous about making that exact same change again over here and would honestly rather just have both yt-dlp and browser_cookie3 use the same lib. That way if there are future issues its a fix in one place instead of multiple. Would using a lib for this be ok? |
@csm10495 Sure! |
Sweet. I've made it really easy. https://pypi.org/project/shadowcopy/
Then to use it:
This will raise if not admin or if called on non-Windows. |
Woot: #185 |
See yt-dlp/yt-dlp#7271 (comment) for a possible non-admin solution here! |
Uses strava PW to create a new sign in session, instead of copying from the browser. Copying the cookie from the browser was not a good solution, requiring some workaround on Windows: borisbabic/browser_cookie3#180 (comment)
[help] Is any body meet this problem on MacOS 15?I tried disable sip and grant full disk access permission to python, but it not works. here's my env
here's traceback Python 3.12.0 | packaged by Anaconda, Inc. | (main, Oct 2 2023, 12:22:05) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import browser_cookie3
>>> browser_cookie3.chrome()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 1160, in chrome
return Chrome(cookie_file, domain_name, key_file).load()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 489, in load
with _DatabaseConnetion(self.cookie_file) as con:
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 349, in __enter__
return self.get_connection()
^^^^^^^^^^^^^^^^^^^^^
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 383, in get_connection
con = method()
^^^^^^^^
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 374, in __get_connection_legacy
shutil.copyfile(self.__database_file, self.__temp_cookie_file)
File "/Users/crash/miniconda3/envs/py312/lib/python3.12/shutil.py", line 260, in copyfile
with open(src, 'rb') as fsrc:
^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted: '/Users/crash/Library/Application Support/Google/Chrome/Default/Cookies' |
Several days ago everything worked fine, and today it broke. Seems like new Chrome update make Chrome to prevent python read cookie file. If I shut Chrome down it works fine again.
Checked on two Win10 PCs - same behavour.
Traceback (most recent call last):
(my own script cut out)
File "E:***.py", line 78, in parse_given_url
cookie_jar = browser_cookie3.chrome(domain_name='domain.name')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Username\AppData\Roaming\Python\Python311\site-packages\browser_cookie3_init_.py", line 1160, in chrome
return Chrome(cookie_file, domain_name, key_file).load()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Username\AppData\Roaming\Python\Python311\site-packages\browser_cookie3_init_.py", line 489, in load
with DatabaseConnetion(self.cookie_file) as con:
File "C:\Users\Username\AppData\Roaming\Python\Python311\site-packages\browser_cookie3_init.py", line 349, in enter
return self.get_connection()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Username\AppData\Roaming\Python\Python311\site-packages\browser_cookie3_init_.py", line 383, in get_connection
con = method()
^^^^^^^^
File "C:\Users\Username\AppData\Roaming\Python\Python311\site-packages\browser_cookie3_init_.py", line 374, in __get_connection_legacy
shutil.copyfile(self.__database_file, self.__temp_cookie_file)
File "C:\Program Files\Python311\Lib\shutil.py", line 256, in copyfile
with open(src, 'rb') as fsrc:
^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'C:\Users\Username\AppData\Roaming\..\Local\Google\Chrome\User Data\Default\Network\Cookies'
The text was updated successfully, but these errors were encountered: