Token error: code: 400, message: bad request #671
Unanswered
nikitanagar62
asked this question in
Q&A
Replies: 1 comment
-
This library is deprecated. The error showed that the email and/or password are not correct or not found in your project users. You should check it by printing it to serial before using it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello mobizt,
I am using this code
`#define TINY_GSM_MODEM_SIM7600 // SIM7600 AT instruction is compatible with A7670
#include <AGS10.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <TinyGsmClient.h>
#include <GSMSimSMS.h>
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
#include "LC709204F.h"
#include <Firebase_ESP_Client.h>
#include <addons/TokenHelper.h>
#include <addons/RTDBHelper.h>
#include "variable.h"
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
TinyGsmClient client(modem);
#define GSM_PIN ""
const char gprsUser[] = "";
const char gprsPass[] = "";
const char apn[] = "";
TinyGPSPlus gps; // The TinyGPSPlus object
SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device
Adafruit_MPU6050 mpu; // MPU6050 Variables
AGS10 sensor = AGS10(); // Alcohol Sensor Variables
LC709204F batteryMonitor; // LC709204F(Battery) sensor variables
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;
double map(double x, double in_min, double in_max, double out_min, double out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void setup() {
Serial.begin(115200);
SerialAT.begin(115200, SERIAL_8N1, 27, 26);
Wire.begin(); // MPU6050
sensor.begin(); // Alcohol sensor
ss.begin(GPSBaud);
pinMode(powerPin, OUTPUT);
digitalWrite(powerPin, HIGH);
Serial.println("Modem Reset, Please Wait");
SerialAT.println("AT+CRESET");
delay(1000);
SerialAT.println("AT+CRESET");
delay(10000);
SerialAT.println("AT+CCID");
SerialAT.println("AT+CGREG?");
delay(1000);
Serial.println("\n---Starting GPS TEST---\n");
SerialAT.println("AT+CGNSSPWR=1,1");
delay(10000);
// Initialize MPU6050
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
Serial.println("Found LC709204F.");
Serial.println("Setting ESP32 thermistor.");
if (!batteryMonitor.setThermistors(true, true)) {
Serial.println("Failed to set thermistor!");
}
Serial.print("BatteryStatus:");
Serial.println(batteryMonitor.getBatteryStatus(), HEX);
Serial.print("ICVersion:");
Serial.println(batteryMonitor.getICVersion(), HEX);
Serial.print("StateOfHealth:");
Serial.println(batteryMonitor.getStateOfHealth(), HEX);
Serial.print(F("Testing TinyGPSPlus library v. "));
Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(" GPS Module Detected");
Serial.println(F("by Mikal Hart"));
Serial.println();
// readGSMModule();
delay(500); // Delay between MPU6050 readings
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
if (!batteryMonitor.init(lc709204f_apa_adjustment_t::LC709204F_APA_1000MAH, lc709204f_battery_profile_t::LC709204F_BATTERY_PROFILE_3_7_V)) {
Serial.println("Couldn't find LC709204F battery monitor!");
delay(1000);
}
Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);
String uid = auth.token.uid.c_str();
Serial.println(uid);
config.api_key = API_KEY;
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
config.database_url = DATABASE_URL;
config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h
fbdo.setGSMClient(&client, &modem, GSM_PIN, apn, gprsUser, gprsPass);
Firebase.reconnectNetwork(true);
fbdo.setBSSLBufferSize(4096 /* Rx buffer size in bytes from 512 - 16384 /, 1024 / Tx buffer size in bytes from 512 - 16384 */);
fbdo.setResponseSize(2048);
Firebase.begin(&config, &auth);
}
void readMPU6050() {
mpu.getEvent(&a, &g, &temp);
ax = (a.acceleration.x);
ay = (a.acceleration.y);
az = (a.acceleration.z);
gx = (g.gyro.x);
gy = (g.gyro.y);
gz = (g.gyro.z);
gyro_delta = (abs(gx - gyrx_prev) + abs(gy - gyry_prev) + abs(gz - gyrz_prev) * 10);
acc_delta = (abs(ax - accx_prev) + abs(ay - accy_prev) + abs(az - accy_prev));
if (acc_delta > acc_thresold && gyro_delta > gyro_thresold) {
accident = "1";
} else {
accident = "0";
}
accx_prev = ax;
accy_prev = ay;
accz_prev = az;
gyrx_prev = gx;
gyry_prev = gy;
gyrz_prev = gz;
}
void readAlcoholSensor() {
randomNumber = random(0, 20);
tvoc = sensor.readTVOC();
}
void readbattery() {
battery = batteryMonitor.getCellVoltage();
battery_voltage = (battery / 1000.0);
battery_percentage = map(battery_voltage, 3.1, 3.8, 0, 100);
if (battery_percentage < 00) {
battery_percentage = 00;
}
if (battery_percentage > 100) {
battery_percentage = 100;
}
}
void readgps() {
while (ss.available() > 0) {
gps.encode(ss.read());
}
if (gps.location.isValid()) {
latitude = gps.location.lat();
longitude = gps.location.lng();
}
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
}
void sendDataOnFirebase() {
if (Firebase.ready() && (millis() - sendDataPrevMillis > 1000 || sendDataPrevMillis == 0)) {
sendDataPrevMillis = millis();
}
}
void loop() {
readMPU6050();
readgps();
readAlcoholSensor();
readbattery();
sendDataOnFirebase();
}
I have assign the credentials in the **variable.h** file and that are correct but facing the issue
Token info: type = id token (GITKit token), status = on requestWaiting for network... success
Connecting to success
Token info: type = id token (GITKit token), status = error
Token error: code: 400, message: INVALID_LOGIN_CREDENTIALS
Token info: type = id token (GITKit token), status = error
Token error: code: 400, message: bad request`
please look on it if you can help in this.
Beta Was this translation helpful? Give feedback.
All reactions