A fictitious example, but one that reproduces my problem, is the following code:
for event_list in client.events(chunk_size = 500_000, data_set_ids = ids_sites):
events = event_list.to_pandas()
Error message after just over an hour: CogniteAPIError: Unauthorized | code: 401 | X-Request-ID: 9c8702fc-59bf-9f7a-be47-4876d6b433f3
In fact, if I iterate in another way (for example, filtering by date), I can run code for more than 8 hours (for as long as I want, actually, because I re-authenticate between iterations, preventing the token from expiring). However, I don't want to filter by date because it doesn't provide consistent data volume like iterating by chunks.
And apparently, I can't authenticate between iterations in the example I provided here, as it seems the chunk persists the initial authentication, which initially makes sense. Does anyone know how to solve this?