Open ianklatzco opened 1 year ago
before a request is made, could prob check if the request is a 401, refresh the token if so, and then try again
by the way, you're looking for com.atproto.server.refreshSession iirc.
will be resolved soon in atproto sdk https://github.com/MarshalX/atproto/issues/12
it has been added in atproto sdk 0.0.6! https://github.com/MarshalX/atproto/pull/27
@MarshalX I seem to be getting an error in 0.0.6
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1179, in refresh_session
response = self._client.invoke_procedure(
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/base.py", line 69, in invoke_procedure
return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs)
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 30, in _invoke
self._refresh_and_set_session()
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 41, in _refresh_and_set_session
refresh_session = self.com.atproto.server.refresh_session(headers=self._get_auth_headers(self._refresh_jwt))
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1179, in refresh_session
response = self._client.invoke_procedure(
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/base.py", line 69, in invoke_procedure
return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs)
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 30, in _invoke
self._refresh_and_set_session()
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 41, in _refresh_and_set_session
refresh_session = self.com.atproto.server.refresh_session(headers=self._get_auth_headers(self._refresh_jwt))
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1179, in refresh_session
response = self._client.invoke_procedure(
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/base.py", line 69, in invoke_procedure
return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs)
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 30, in _invoke
self._refresh_and_set_session()
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 41, in _refresh_and_set_session
refresh_session = self.com.atproto.server.refresh_session(headers=self._get_auth_headers(self._refresh_jwt))
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1179, in refresh_session
response = self._client.invoke_procedure(
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/base.py", line 69, in invoke_procedure
return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs)
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/client.py", line 29, in _invoke
if self.me and self._should_refresh_session():
File "/mnt/mpathaf/scratch/hidden/atproto-embed/lib/python3.10/site-packages/atproto/xrpc_client/client/methods_mixin/session.py", line 12, in _should_refresh_session
expired_at = datetime.fromtimestamp(self._access_jwt_payload.exp, tz=timezone.utc)
RecursionError: maximum recursion depth exceeded while calling a Python object
the final two lines are unique, as the stacktrace is 2000+ lines long
@Scrxtchy could you show the output of
from datetime import datetime, timezone
d = datetime.now(timezone.utc)
print(d)
from the machine where you are getting the error pls
ah, I think I found this bug. will be fixed asap, thank you!
thanks, and if it's of any future use
>>> from datetime import datetime, timezone
d = datetime.now(timezone.utc)
print(d)>>> d = datetime.now(timezone.utc)
>>> print(d)
2023-05-20 14:30:28.278565+00:00
I should be reporting this on the right repo, sorry I clicked the wrong linked issue from the PR
@Scrxtchy fixed in 0.0.7 (https://github.com/MarshalX/atproto/pull/33). Pls let me know is everything fine
https://github.com/ianklatzco/atprototools/blob/52b046642baad183f77ba4eaab4ac704eaf5acdb/atprototools/__init__.py#L40