Base64 Authentication Python

前端 未结 4 657
滥情空心
滥情空心 2021-02-01 15:03

I\'m following an api and I need to use a Base64 authentication of my User Id and password.

\'User ID and Password need to both be concatenated and then Base64 encoded\'

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 15:16

    With python3, I have found a solution which is working for me:

    import base64
    userpass = username + ':' + password
    encoded_u = base64.b64encode(userpass.encode()).decode()
    headers = {"Authorization" : "Basic %s" % encoded_u}
    

提交回复
热议问题