I'm trying to access an API which has requires authentication. However I keep getting the error which reads " a bytes-like object is required, not 'str' " for the base64encode line.
user = input("user: example")
password = getpass.getpass("password: example1234")
authCred = base64.b64encode(user + ":" + password)
I tried to change the code to:
user = input("user: example")
password = getpass.getpass("password: example1234")
authCred = base64.b64encode(user.encode('ascii') + ":" + password.encode('ascii')).decode('ascii')
But then I get the error "can't concat str to bytes"
Does anyone know how I can fix this?