You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a daemon application that needs to call an API endpoint every X seconds and whenever the token expires the application stop with the following error:
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 787, in request
return self.send(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 878, in send
response = self._send_handling_auth(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 905, in _send_handling_auth
request = next(auth_flow)
File "/usr/local/lib/python3.8/site-packages/httpx/_auth.py", line 67, in sync_auth_flow
request = next(flow)
File "/usr/local/lib/python3.8/site-packages/httpx_auth/authentication.py", line 284, in auth_flow
token = OAuth2.token_cache.get_token(
File "/usr/local/lib/python3.8/site-packages/httpx_auth/oauth2_tokens.py", line 132, in get_token
new_token = on_missing_token(**on_missing_token_kwargs)
File "/usr/local/lib/python3.8/site-packages/httpx_auth/authentication.py", line 294, in request_new_token
token, expires_in = request_new_grant_with_post(
File "/usr/local/lib/python3.8/site-packages/httpx_auth/authentication.py", line 65, in request_new_grant_with_post
with client:
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1239, in __enter__
raise RuntimeError(msg)
RuntimeError: Cannot reopen a client instance, once it has been closed.
Looking at the implementation of your client it seems you are using a context manager for managing it. This works correctly only once, because if you use the same httpx client when it enter this function again, the context manager has already closed the connection and that's why the error occurs.
To reproduce the issue just create an httpx client without a context manager and wait till the renewal needs to be done.
The text was updated successfully, but these errors were encountered:
Hi!
I have a daemon application that needs to call an API endpoint every X seconds and whenever the token expires the application stop with the following error:
Looking at the implementation of your client it seems you are using a context manager for managing it. This works correctly only once, because if you use the same httpx client when it enter this function again, the context manager has already closed the connection and that's why the error occurs.
To reproduce the issue just create an httpx client without a context manager and wait till the renewal needs to be done.
The text was updated successfully, but these errors were encountered: