I need to fetch data from Inhouse API where credentials need to encoded using base64.
import base64
import requests
username = 'root'
password = '1234'
auth_str = '%s:%s' % (username, password)
b64_auth_str = base64.b64encode(auth_str)
headers = {'Authorization': 'Basic %s' % b64_auth_str}
#content_res = requests.get(get_url, headers=headers).json()
Above is my code. This throws up error on line where encoding username and password.
TypeError: a bytes-like object is required, not 'str'
Any work around?