[711638] Connecting to blynk-cloud.com:80 [712226] Invalid auth token

Hi all
I’m new to Blynk and had my first success with ESP8266.
When I tried using the ESP32 (WROOM-32) the program downloads but I seem to always get “invalid auth token”.
It sounds like a common problem, but I cannot find a solution anywhere.
I have made sure the auth code is accurate, i’ve refreshed it a few times both in the code and the iPhone and still it comes up with
[711638] Connecting to blynk-cloud.com:80
[712226] Invalid auth token
over and over again.
Any help would be greatly appreciated.
George

int pin        = 5;
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "TMBaTZ8HW525lyyUncyWJDp8WpOP-Plu";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXXX";
char pass[] = "XXXXXXXX";

void setup() {  
  pinMode(pin, OUTPUT); 
  pinMode(pin, HIGH);
  Serial.begin(115200);

  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, pass);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");  
  Blynk.begin("Your auth token key", ssid, pass);
}

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

```cpp

void loop()

@gayoub please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Okay, this line of code…

char auth[] = "TMBaTZ8HW525lyyUncyWJDp8WpOP-Plu";

stores your Blynk Auth code on a variable called auth.

The problem is that this variable isn’t used anywhere else in your code. It should be used when you use the Blynk.begin command to create the connection to the Blynk server, like this…

Blynk.begin(auth, ssid, pass); 

but instead your code used this…

Blynk.begin("Your auth token key", ssid, pass);

So Blynk is complaining because it’d being told to use the auth code of Your auth token key instead of TMBaTZ8HW525lyyUncyWJDp8WpOP-Plu

Also, all of this code is redundant…

because it’s establishing a WiFi connection, but Blynk.begin(auth, ssid, pass); handles all of that for you.

Pete.

Thanks very much. Not sure how I missed it.
Grateful for your help
Working now :slight_smile:
George

1 Like

@111140 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.