In Python 3, I'm passing credentials to authenticate an API call and it works completely fine using the following line:
userAndPass = b64encode(b"username:password").decode("ascii")
For security purposes, what I would prefer to do is store the credentials externally (possibly a yaml file or elsewhere) rather than hard code it. I attempted to replace the username and pass with variables, but that doesn't seem to work. I've tried placing the variable 'credentials' in brackets and also tried adding a plus before hand, neither work.
I would like it to work as follows:
credentials = "username:password"
userAndPass = b64encode(b'credentails').decode("ascii")
Any suggestion is appreciated!