Every time I run this code with a wild card (max_users = '*') or >140 I get this error JSONDecodeError: Expecting value: line 1 column 1 (char 0). But are <140 value it works fine not just all the user are returned.
Does anyone know what I'mWhat am I doing wrong.?
def datetime_of_last_login(user) -> dt.datetime:
timestamp_of_last_login = int(user.lastLogin / 1000)
last_login = dt.datetime.fromtimestamp(timestamp_of_last_login)
return last_login
def num_days_since_last_login(user) -> int:
last_login = datetime_of_last_login(user)
now = dt.datetime.now()
return (now - last_login).days
users = gis.users.search(query='*', max_users=140)
for user in users:
cd = dt.datetime.fromtimestamp(user.created / 1000).strftime('%Y-%m-%d %H:%M:%S')
last_login_datetime = datetime_of_last_login(user)
days_since_last_login = num_days_since_last_login(user)
print("_____________________________________________________________")
print(f"User: {user.username}")
print(f"Role: {user.role}")
print(f"Email: {user.email}")
print("Creation Date:", cd)
print("Last Login:", last_login_datetime)
print("Days Since Last Login:", days_since_last_login)
if days_since_last_login > 90:
print (f"User:{user.username}")