FAILED REASON: missing required credentials e.g., database URL, host . error esp8266

#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>

// Replace with your network credentials
#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PASSWORD "your_wifi_password"

// Replace with your Firebase project settings
#define API_KEY "your_firebase_web_api_key"
#define DATABASE_URL "your-project-id.firebaseio.com" // without https://

// Firebase objects
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

void setup() {
Serial.begin(115200);

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println(" connected.");

// Assign Firebase credentials
config.api_key = API_KEY;
config.database_url = DATABASE_URL;

// Anonymous sign-in (leave email/password blank)
auth.user.email = "";
auth.user.password = "";

// Start Firebase
Firebase.begin(&config, &auth);
Firebase.reconnectWiFi(true);

// Wait for sign-in to complete
while (!Firebase.ready()) {
Serial.println("Waiting for Firebase to be ready...");
delay(1000);
}

Serial.println("Firebase is ready!");
Serial.println("UID: " + auth.token.uid);

// Push test data
if (Firebase.setString(fbdo, "/test_path/message", "Gas Sensor Ready")) {
Serial.println("Data sent to Firebase!");
} else {
Serial.println("Failed to send: " + fbdo.errorReason());
}
}

void loop() {
// optional: send data repeatedly
}
I have give correct api key and url
FAILED REASON: missing required credentials e.g., database URL, host . error

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination

hello, i just wanted to ask if you already have resolved this? I am getting the same error.

@mj_12312
You should start your own topic to get help for your own issue.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.