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

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -