import urllib.request, json body = json.dumps({'email':'admin@talos.com','password':'admin123'}).encode() r = urllib.request.Request('http://localhost:8000/api/v1/auth/login', data=body, headers={'Content-Type':'application/json'}) token = json.loads(urllib.request.urlopen(r).read())['access_token'] r2 = urllib.request.Request('http://localhost:8000/api/v1/attendances/today', headers={'Authorization':f'Bearer {token}'}) resp = urllib.request.urlopen(r2) data = json.loads(resp.read().decode()) for item in data: if item.get('is_late'): print(f"{item['user_name']} - LATE: {item['late_reason']} by {item['late_authorized_by']}") else: print(f"{item['user_name']} - on time")