There's really no magic to storing credentials. You can obfuscate them, encrypt them, and so on. But, since the end user ultimately has to use them, they are plaintext somewhere at some time.
Some people use a software vault. The end user can still play games and get the password, but with a vault, you at least have a central place to control who gets the key, expiration dates, changing it, etc. Hashicorp's Vault is popular in this space.