Fix for 2610

_ks_cached_user_id can be initialized with different value due to blocking call in json_request. It can cause infinite recursion. Avoid global variable and recursive function