New INO file, with modified WiFiManager.cpp and WiFIManager.h. As in my previous post, install WiFiManager, backup original .h and .cpp files, and replace with this modified ones.
Cayenne token is written in JSON file ON ESP (I use Wemos D1 Mini, I guess it works on any other ESP8266, with little or no modification). This is WiFiManager built-in functionality which I used to make this for me
If WiFi connection isn't set, it will start AP config mode, with field to enter Cayenne token. Also, it can be done on demand, shorting D5 pin. On start, shorting D5 and D6 pin will erase json file, and will be needed to set everything again - real hard reset. If D6 is shorted before D5 but while ESP works, JSON file won't be erased, and WIFi config will be entered - connection reset. If nothing is shorted, after power loss and return, ESP will work with saved data.
By start I mean power off / power on, not reset button.
I haven't found bugs so far, but there might be some. I'm not good programmer.
Also, there is a lot serial debug left. Delete all that isn't needed.
There is also 45% space used. All libraries included in INO file ARE needed.
I really hope that this solves someones problems. I know it does mine
Oh, and one more, last thing: all credits goes to WiFiManager and Cayenne developers, I didn't do almost nothing except combining this into one (I hope) neat concoction