BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Invalid Auth token in local server

Hola he instalado un server local sin problemas. La app se conecta Ok con el server, pero cuando programo el firmware en el hardware y lo ejecuto al intentar conectarse al server aparece el mensaje Invalid Auth Token. Tengo instalado el server-0.41.11-java8.jar sobre windows 10. Les agradecería una respuesta. Atte Miguel

Did you create your project while the app was linked to your local server?

Pete.

Hi Pete, thanks for communicating. If the app links well with the server, the user’s access is even registered in the server’s log. On the other hand when I run the app it indicates that the har is not connected: “Wasn’t online yet”

So once the phone is connected to the local server, did you create a new project using the phone?

Pete.

yes Pete. For example: I take the Token of the project and include it in the firmware of a NodeMCU board - Wifi

And what settings for the local server did you use in your NodeMCU sketch, and what are you seeing in the serial monitor for the NodeMCU?

Pete.

This is my program
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include “DHT.h” // including the library of DHT11 temperature and humidity sensor
#include <SimpleTimer.h> //including the library of SimpleTimer
#define DHTTYPE DHT22 // DHT 11

#define dht_dpin 14
DHT dht(dht_dpin, DHTTYPE);
SimpleTimer timer;
char auth[] = “7VL0vHrwENveIC4DwjZ5ACP8-mtNyG2W”;

char ssid[] = “ELO”; // Your WiFi credentials.
char pass[] = “josefina2”; // Set password to “” for open networks.
float t; // Declare the variables
float h;

const int salida = 12;

void setup()
{
pinMode(salida,OUTPUT);
Serial.begin(9600);// Debug console
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(2000, sendUptime);
}

void sendUptime()
{

float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.println(“Humidity and temperature\n\n”);
Serial.print("Current humidity = “);
Serial.print(h);
Serial.print(”% ");
Serial.print("temperature = ");
Serial.println(t);
Blynk.virtualWrite(V0, t);
Blynk.virtualWrite(V1, h);

}

void loop()
{
Blynk.run();
timer.run();
}

This won’t get you connected to your local server.

Pete.

While the serial monitor indicates Invalid Auth Token

why?

Because you haven’t told the Blynk library where to find your local server (IP address) and which port to use.
Without this information the Blynk library will default to trying to connect to blynk-cloud.com as you’ll see in the serial monitor.

Pete.

If you take a look at any of the examples in the Sketch Builder you’ll see:

Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

Pete.

Ok, I didn’t understand this point, although I thought the token was stored in BLYNK. This means that you could use the entire system on a private network without an internet connection?

A Blynk project, and it’s associated Auth tokens are only stored one one server. Even the three Blynk cloud servers don’t replicate the projects.

A local server could be used without any internet connection, but push notifications, Twitter and email wouldn’t work. (I suppose email would work if you had your own mail server on the same network).
If you used it in this way then your phone would need to be connected to the same network by Wi-Fi, so you wouldn’t have any access to Blynk when you were away from the network.

Pete.

Thank you very much Pete for the help !!! It has worked correctly. Grateful to the Blynk community

1 Like