I have a couple of long-running processes (20-30 minutes) for synchronizing data from ArcGIS Online to an Azure database.
Most of the time these processes complete without issue, but occasionally I'll get a "Token Required" error (code 499) midway through the process. It could happen at any point in the processes, although it's usually in the latter part, and could happen on any call - query(), query_related_records(), etc.
This is occurring with multiple processes, and has been replicated from multiple desktop machines with different ArcGIS Pro versions.
My theory is the token is expiring but I don't really have any evidence to support that, and I would've expected the error message to be something about an invalid token rather than "token required".
Has anyone else run into this and been able to identify the problem, and if so, is there a "clean" workaround?
You can check the expiration time of the current session token and print it before each call to see if that is the issue:
>>> gis._con._session.auth._expiration_time
datetime.datetime(2025, 6, 28, 22, 13, 5, 762930)