I’d suggest that you look at either the Blynk Provisioning examples in the Arduino IDE, WiFi Manager, or this library:
Pete.