ESP32 Firebase:身份验证导致错误代码 400 - 但 Firebase 确实识别我的登录

ESP32 Firebase: authenticating results in error code 400 - but Firebase does recognize my login

我正在尝试使用 signIn() 方法和 来自 ESP32 Client library (the new version)

的示例代码 的精确副本进行身份验证

在我的串口监视器中,我可以看到 error code is 400 这个:

我使用的代码:

Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);

/* Assign the api key (required) */
fb_config.api_key = API_KEY;

/* Assign the user sign in credentials */
fb_auth.user.email = email_name.c_str();
fb_auth.user.password = email_name.c_str();

/* Assign the RTDB URL */
fb_config.database_url = DATABASE_URL;

Firebase.reconnectWiFi(true);
fb_do.setResponseSize(4096);

/* Assign the callback function for the long running token generation task */
fb_config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h

/** Assign the maximum retry of token generation */
fb_config.max_token_generation_retry = 5;

/* Initialize the library with the Firebase authen and config */
Firebase.begin(&fb_config, &fb_auth);

if(Firebase.authenticated()){
  Serial.println("I am authenticated");
} else {
  Serial.println("Well I AM NOT???");
}

我的 Firebase 身份验证截图显示我的 ESP32 已创建并且今天也已登录:

我知道我的 Firebase 初始化成功了,因为我可以读取数据并将读取的数据写入实时数据库:

我正在使用 PlatformIO,这是我的配置文件:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
build_flags = -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
lib_deps = 
    mobizt/Firebase Arduino Client Library for ESP8266 and ESP32@^2.5.4
    bblanchon/ArduinoJson@^6.18.5
  • 问题是我正在检查 Firebase.authenticated()方法太早了,Firebase没有 有时间验证。
  • 如果我在主要 loop() 中检查它,它会起作用。

GitHub discussion 我们在哪里找到解决方案。