This is a follow-up article to the Tasker credentials article. I mentioned, that If you run a NodeRED server, you can pass an authenticated web request to obtain these credentials from your own server, without sharing the file with Google Docs. The Tasker part of the process remains the same, so please check that tutorial out, as here I’m going to cover the NodeRED endpoint.

NodeRED Credentials

I’m going to work again with HTTP requests and JSON files so if you need a bit of background knowledge, I have the JSON basics for you here. Making an authenticated request with a GET HTTP request is very easy.

First, we have to store the credentials in a file (you can also store it in a node if you prefer) – I have created the credentials.txt file using the setup below:

 {
"NodeRED_IP": "192.168.1.183:1880",
"HomeDNS": "DNS1.ddns.net",
"MQTT_user": "MQTTuser",
"MQTT_pass": "MQTTpass",
"HTTP_user": "HTTPuser",
"HTTP_pass": "HTTPpass"
}

Once the authenticated (username, password) GET HTTP request is issued, the node will serve the JSON object with your details stored in the credentials.txt. Depending on your needs, you can save it in a file  (as I have done so in the Tasker example) or use the JSON object directly.

Please note, this is not the best solution if your credentials contain the server’s IP. If your NodeRED DNS or IP changes, you will have to update the script pulling the JSON file manually. You can bypass this by serving the updated JSON file first, then changing the IP of the server.

Conclusion

Storing your credentials this way introduces a new level of safety as only authenticated HTTP requests will get a valid response. If you want to learn more about securing your NodeRED installation – check this article out.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE