ESP32 Firebase: authenticating results in error with no message – but Firebase does recognize my login

  arduino, c++, esp32, firebase

I am trying to authenticate using signIn() method and example code from ESP32 Client library (the new version)

  • When I run my code I successfully connect to WiFi and also I can
    successfully CREATE new account from the ESP32 board.
  • When I then save the email/pass to the flash and restart the ESP32 or
    even right after the successful register – the function
    Firebase.authenticated() returns always False
  • I need to know if my log in or registration was successful
  • In my Firebase authentication signup with email/pass is enabled.

Also very strange thing is that in my Serial monitor fb_config.signer.signupError.message.c_str() returns an empty string:

enter image description here

Code that I am using:

void connectToFirebase(){    
  Serial.println("-----------------------");
  Serial.printf("Firebase Client v%snn", FIREBASE_CLIENT_VERSION);

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

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

  /* 
  If I only want to log in use this???
  */
  //fb_auth.user.email = email_name.c_str();
  //fb_auth.user.password = email_pass.c_str();

  /* Sign up */
  if (Firebase.signUp(&fb_config, &fb_auth, email_name, email_pass)){
    Serial.println("ok");
  }
  else{
    Serial.printf("Error occured: %sn", fb_config.signer.signupError.message.c_str());
  }

  Firebase.begin(&fb_config, &fb_auth);  
  Firebase.reconnectWiFi(true);
  fb_do.setResponseSize(4096);

  //IDK why this doesnt work - but it should
  if(Firebase.authenticated()){
    Serial.println("I am authenticated");
  }

  Serial.println("-----------------------");
}

Uncommenting or commenting this lines have no effect on the code:

fb_auth.user.email = email_name.c_str();
fb_auth.user.password = email_pass.c_str();

Screenshot from my Firebase authentication that my ESP32 was created and also logged in today:

enter image description here

I know my Firebase initialization was successful because I can read and write read data into the Realtime database:

enter image description here

I am using PlatformIO and this is my config file:

[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 [email protected]^2.5.4
    bblanchon/[email protected]^6.18.5

Source: Windows Questions C++

LEAVE A COMMENT