I will admit I only sort of know what I am doing, especially around SSL. Help appreciated, especially if I am doing something stupid.
I am trying to setup a command to Rachio (gen 3) to turn on a valve when my fountain level goes low. Using an ESP8266 and c-code.
For a test, I am only trying to get my person ID.
On my PC with a Win 10 CMD window, if I use the following command and0 I get my personal ID (I also have curl commands that work for turning on the valve, but lets keep this simple):
curl -v https://api.rach.io/1/public/person/info -H âAuthorization: Bearer my-bearer-API-idâ
That suggests I have the correct bearer and since a valve works, I also have my personal ID.
I want to code that in the ESP8266. I have the SSL certificate and fingerprint updated. Below is the code. It succeeds in the initial 'client.connect", but when I then ask for the info, I get a message:
{âerrorsâ:[{âmessageâ:âThe client is not authorized.â}]}
When I do the curl command -v (verbose) I get a LOT of handshaking messages and get more info messages which I think must be the secure permissions activity.
Any thoughts on my code? Or is there a higher level of security that Rachio uses that an ESP8266 doesnât support?
Parts of ESP8266 code
âŚ
const char fingerprint PROGMEM = â8f9ae2ecdf807656888d6f68b80e3a95f55e39cfâ;
const char* host = âapi.rach.ioâ;
const int httpsPort = 443;âŚ
WiFiClientSecure client;
client.setFingerprint(fingerprint);
Serial.print("Connecting to ");
Serial.println(host);if (!client.connect(host, httpsPort)) {
Serial.println(âConnection failedâ);return;
}
String url = â/1/public/person/infoâ;
Serial.print("Requesting URL: ");
Serial.println(url);client.print(String("GET â) + url + " HTTP/1.1\r\nâ +
"Host: " + host + â\r\nâ +
âAuthorization: Bearer 219b20a9-xxxx-xxxx-xxxx-6e887f2dxxxxâ +
âConnection: close\r\n\r\nâ);Serial.println(âRequest sentâ);
while (client.connected()) {
String line = client.readStringUntil(â\nâ);
if (line == â\râ) {
Serial.println(âHeaders receivedâ);
break;
}
}
String line = client.readStringUntil(â\nâ);Serial.println(âReply was:â);
Serial.println(â==========â);
Serial.println(line);
Serial.println(â==========â);
Serial.println(âClosing connectionâ);
}