-
Notifications
You must be signed in to change notification settings - Fork 20
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
"PermissionError" when Initialising a Client w/ "browser-cookie3" #10
Comments
PermissionError
when initialising a client with browser-cookie3
PermissionError
when initialising a client with browser-cookie3
The full log: Traceback (most recent call last):
File "/Users/<my_user_name>/<path_to_file>/ask_gemini.py", line 23, in <module>
asyncio.run(main())
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/<path_to_file>/ask_gemini.py", line 11, in main
client = GeminiClient()
^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/site-packages/gemini_webapi/client.py", line 129, in __init__
cookies = browser_cookie3.load(domain_name="google.com")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 1233, in load
for cookie in cookie_fn(domain_name=domain_name):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 1223, in safari
return Safari(cookie_file, domain_name).load()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 1040, in __init__
self.__open_file(cookie_file)
File "/Users/<my_user_name>/anaconda3/envs/<conda_env_name>/lib/python3.12/site-packages/browser_cookie3/__init__.py", line 1051, in __open_file
self.__buffer = open(cookie_file, 'rb')
^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted: '/Users/<my_user_name>/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies' |
❌ Update:Tried (Cookie's path: ✅ Update 2:Tried modifying the following function from # __init__.py in browser-cookie3
def load(domain_name=""):
"""Try to load cookies from all supported browsers and return combined cookiejar
Optionally pass in a domain name to only load cookies from the specified domain
"""
cj = http.cookiejar.CookieJar()
for cookie_fn in [chrome, chromium, opera, opera_gx, brave, edge, vivaldi, firefox, librewolf, safari]:
try:
if cookie_fn == safari: # ignore safari
continue
for cookie in cookie_fn(domain_name=domain_name):
cj.set_cookie(cookie)
except BrowserCookieError:
pass
return cj |
Did this happen while initializing client with from gemini_webapi import GeminiClient, set_log_level
set_log_level("DEBUG")
client = GeminiClient(Secure_1PSID, Secure_1PSIDTS)
await client.init(auto_refresh=True) |
Hey developer,
When I am using
browser-cookie3
to initialise a client:It shows up the following error:
PermissionError: [Errno 1] Operation not permitted: '/Users/<my_user_name>/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies'
It seems like an error related to Safari. My current OS is
macOS 14.3.1 23D60 arm64
, and I'm pretty sure my default browser is not Safari.(When I manually use
__Secure-1PSID
and__Secure-1PSIDTS
, it works fine but theIPSIDTS
still expires very quickly. It can last 5 mins when I'm using an incognito tab on Chrome.)Is there any way to customise browser options from `browser-cookie3? Or is there any way to grant permissions to avoid the error?
Thanks for your awsome work : )
Yifan
The text was updated successfully, but these errors were encountered: