HomeTaskerA better way to store Tasker credentials

A better way to store Tasker credentials

The more clever way of managing credentials

I do Tasker tutorials, I also share the files for you to download. This means I have to be very careful what information I share with you guys. I don’t want my personal keys, passwords and IP addresses to be available online. I spoke about the most important Tasker variable before, and this time I will show you how to store and authenticate your Tasker profiles properly.

The idea is pretty simple. I want to have a single file stored on Google Drive which will contain all the security information. The file’s URL will be shared with Tasker – which will handle the credentials. Some of you will shout at me for making the file shareable through the link, but the chances of actually finding this file just by the link are pretty slim. If you have RaspberryPi and NodeRED you can serve this JSON file from your own server (tutorial here something that I will do personally) with increased security (providing your NodeRED is secure).

Creating JSON file for Tasker credentials

For an easy access, I’m storing the values as JSON file. This way I can quickly access it with AutoTools JSON Read action. The file has the following structure:

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

Simply save this (edited to your liking) as credentials.txt and upload it to your Google Drive. Enable sharing by link and copy the URL. Pay attention to the URL as I need to change the way it has been constructed.

https://drive.google.com/uc?authuser=0&id=XXXXXXXXXXXX&export=download

Grab the file ID from your URL and enter it instead of the XXXXXXXXXXXX above. Now you have an HTTP Get ready URL for Tasker

Tasker credentials profile

TASKER PROFILE: Set Credentials On Boot
Profile: Set Credentials On Boot 
	Event: Device Boot
Enter: Set Credentials 
	A1: Variable Set [ Name:%fileid To:XXXXXXXXXXXXXXXXXX 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: HTTP Get [ Server:Port:https://drive.google.com/uc?authuser=0&id=%fileid&export=download 
		Path: Attributes: Cookies: User Agent: Timeout:10 Mime 
		Type:text/* Output File:Download/credentials.txt 
		Trust Any Certificate:Off ] 
	A3: AutoTools Json Read [ Configuration:Input Format: Json
		Simple Mode: true
		Json: /storage/emulated/0/Download/credentials.txt
		Fields: NodeRED_IP,HomeDNS,MQTT_user,MQTT_pass,HTTP_user,HTTP_pass
		Separator: , Timeout (Seconds):60 ] 
	A4: Delete File [ File:Download/credentials.txt Shred Level:0 Use Root:Off ] 
	A5: Variable Set [ Name:%NODEREDIP To:%nodered_ip 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A6: Variable Set [ Name:%DNS To:%homedns 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A7: Variable Set [ Name:%HTTPpass To:%http_pass 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A8: Variable Set [ Name:%HTTPuser To:%http_user 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A9: Variable Set [ Name:%MQTTpass To:%mqtt_pass 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A10: Variable Set [ Name:%MQTTuser To:%mqtt_user 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A11: Flash [ Text:
		  DNS: %homedns
		  HTTP User: %http_user
		  HTTP Pass: %http_pass
		  MQTT User: %mqtt_pass
		  MQTT Pass:%mqtt_user
		  NodeRED IP %nodered_ip 
		 Long:Off ] 

On boot, Tasker will download the file and store the credentials locally. The global variables will get updated and the file will be removed. To increase the security of Tasker, simply add the passcode to it. Going forward, all you have to do to change your credentials is update the credentials.txt and reboot your phone.

Please note that we are storing the credentials in Google Docs, so to edit the file you have to use some sort of text editor. I’m using Anyfile-Notepad – this way I can modify the file in Google Docs and the changes will apply on the next reboot of the phone. Alternatively, use Google Sync, and you can edit the file directly from the Windows’ notepad.

Assign Global Variables

AutoTools JSON Read action will read the JSON file from the text file and make it all available as local variables. If you want to learn more about JSON structure, I have a tutorial about it too. To access each value, you have to look for the “key” name. In the “Fields” option list:

NodeRED_IP,HomeDNS,MQTT_user,MQTT_pass,HTTP_user,HTTP_pass

You will have the values available as %nodered_ip, %homedns etc.  Use the variables to set your corresponding Tasker variables.

Once you have the variables assigned, it’s cleanup time. Delete the credentials.txt file using Tasker – File Delete and secure the Tasker with a password.

Conclusion

To increase the security of the setup, you could store the credential.txt on your own server behind the authenticated HTTP request. You could totally set one up using NodeRED. This way, the file is not shared with any other parties. You can enhance the modified EventGhost credentials too. Take a look at this tutorial to learn how to store the credentials globally in the EventGhost.

As you can see, storing Tasker credentials this way can help you manage it better without the risk of sharing it accidentally with others. Also, any changes made to the file would apply globally after the reboot. It will save me a lot of work, but I have to adjust all my connected profiles first.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?