I recommend placing secrets in a JSON file in Ignition's main install folder (outside the data/ subfolder). That will exclude it from gateway backups. Set permissions on the file so only the Ignition service user can read the file.
In a project library script, read the file and decode it into a python top-level variable. Other functions in that script will be able to retrieve the secrets as needed.
In your dev environment, place a file with testing credentials in the same place.