api - Base64 Authentication Python -
i'm following api , need use base64 authentication of user id , password.
'user id , password need both concatenated , base64 encoded'
it shows example
'userid:password'
it proceeds 'provide encoded value in "authorization header"'
'for example: authorization: basic {base64-encoded value}'
how write python api request?
z = requests.post(url, data=zdata )
thanks
you can encode data , make request doing following:
import requests, base64 usrpass = "userid:password" b64val = base64.b64encode(usrpass) r=requests.post(api_url, headers={"authorization": "basic %s" % b64val}, data=payload)
i'm not sure if you've add "basic" word in authorization field or not. if provide api link, it'd more clear.
Comments
Post a Comment