I have to make a post to a rest server in python. In header authentication I have to include a base64 encoded string.
I do it with base64 module:
import base64
#node here is '3180' but I also tried with text
node = base64.b64encode(node.encode('utf-8'))
node = 'Basic ' + str(node)
headers = {'Content-type': 'application/json', 'Authentication': node}
print(headers)
And what I get in print is:
{'Authentication': "Basic b'MzE4MA=='", 'Content-type': 'application/json'}
Which has b' ... ' added to node base64 string. Is there a way to avoid those characters to appear? I don't know if they just appears in prints or also are sent to the server.