error {"code":-2008,"msg":"Invalid Api-Key ID."}

Faced with a bug that I can’t solve. Support can’t help since it’s a third party library. I will be glad to help, thank you all.
Below I will provide the code where this error occurs.

Переменная состояния, указывающая на выполнение операций

is_processing = False

@dp.message_handler(lambda message: message.text == “:white_check_mark:Поиск:white_check_mark:”)
async def search_button_handler(message):
global is_processing
if is_processing:
await bot.send_message(message.chat.id, “:warning: Операции уже выполняются”)
return

is_processing = True
user_id = message.from_user.id
user = db.get_user_by_id(user_id)

if user:
    api_key = user['BINANCE_API_KEY']
    api_secret = user['BINANCE_API_SECRET']
    try:
        # Обращение к тестовой спотовой сети Binance и получение всех валют
        client = ccxt.binance({
            'apiKey': api_key,
            'secret': api_secret,
            'options': {
                'defaultType': 'future',
                'test': True
            }
        })
        exchange_info = client.fetch_markets()
        symbols = [symbol['symbol'] for symbol in exchange_info]
        print(symbols)
        # Получение стоимости каждой валюты в USDT
        prices = client.fetch_tickers()
        usdt_prices = {symbol: float(prices[symbol]['last']) for symbol in prices if symbol.endswith('USDT')}
        print(usdt_prices)
        # Получение баланса пользователя на тестовой спотовой сети Binance
        account_info = client.fetch_balance()
        balances = {balance: float(account_info['total'][balance]) for balance in account_info['total']}
        print(balances)
        # Получение баланса пользователя из базы данных
        balance_from_database = db.get_balance(user_id)
        print(balance_from_database)
        if balance_from_database is not None and balances['USDT'] >= balance_from_database:
            for symbol in symbols:
                if symbol != 'USDT' and symbol.endswith('USDT'):  # Исключаем пару USDT -> USDT и другие недопустимые пары

                    # Проверка доступности пары для обмена
                    if symbol in symbols:
                        # Обмен USDT на пару
                        trade_pair = symbol
                        filters = next((filter for filter in exchange_info if filter['symbol'] == trade_pair), None)
                        if filters:
                            quantity_filter = next((f for f in filters['info']['filters'] if f['filterType'] == 'LOT_SIZE'), None)
                            if quantity_filter:
                                step_size = float(quantity_filter['info']['stepSize'])
                                min_quantity = float(quantity_filter['info']['minQty'])
                                if balance_from_database >= min_quantity:
                                    quantity_to_buy = round(balance_from_database / step_size, quantity_filter['info']['stepSize'])
                                    buy_order = client.create_order(
                                        symbol=trade_pair,
                                        type='market',
                                        side='buy',
                                        quantity=quantity_to_buy
                                    )

                                    # Получение обновленного баланса после обмена
                                    account_info = client.fetch_balance()
                                    updated_balances = {balance: float(account_info['total'][balance]) for balance in account_info['total']}
                                    updated_balance = updated_balances['USDT']

                                    # Проверка увеличения баланса
                                    if updated_balance >= balance_from_database * 1.0001:
                                        # Обратный обмен пары на USDT
                                        sell_order = client.create_order(
                                            symbol=trade_pair,
                                            type='market',
                                            side='sell',
                                            quantity=updated_balance
                                        )

                                        # Получение обновленного баланса после обратного обмена
                                        account_info = client.fetch_balance()
                                        updated_balances = {balance: float(account_info['total'][balance]) for balance in account_info['total']}
                                        updated_balance = updated_balances['USDT']

                                        # Отправка сообщения пользователю с обновленным балансом
                                        message_text = f"При обмене с парой {trade_pair}:\nБаланс до: {balance_from_database}\nБаланс после: {updated_balance}"
                                        await bot.send_message(message.chat.id, message_text)
                                    else:
                                        await bot.send_message(message.chat.id, f"❌ Обмен с парой {trade_pair} не увеличивает баланс на 0.01%")
                                else:
                                    await bot.send_message(message.chat.id, f"❌ Баланс пользователя меньше минимального размера лота для пары {trade_pair}")
                            else:
                                await bot.send_message(message.chat.id, f"❌ Не удалось найти фильтр лота для пары {trade_pair}")
                        else:
                            await bot.send_message(message.chat.id, f"❌ Пара {symbol} недоступна для обмена")
                    else:
                        await bot.send_message(message.chat.id, f"❌ Пара {symbol} недоступна для обмена")

                    # Проверка нажатия кнопки "Стоп"
                    if message.text == "📛Стоп📛":
                        await bot.send_message(message.chat.id, "⛔️ Операции остановлены")
                        is_processing = False
                        break

            is_processing = False
    except ccxt.BaseError as e:
        print(f"Error in search_button_handler: {e}")
        await bot.send_message(message.chat.id, "❌ Произошла ошибка при выполнении операции")
        is_processing = False
else:
    await bot.send_message(message.chat.id, "❌ Пользователь не найден в базе данных")
    is_processing = False

Thanks for the feedback, we recommend to ask question in English, it will be easier for us to understand the topic.

Based on the error message, please double check if the API key sent to server is the correct one.

The key was checked many times, changed, no problems with the key