i trying make http api call 1 of server, support http basic authentication using api key in base64 encoding. want add authorization header in base64 encoding request.
the 1 method of authorization know is:
>>> import requests >>> r = requests.get('https://test.com/test-api-gateway/v0/deployments', auth=('user', 'password'), verify=false)).text >>> print r {"statuscode":401,"statusmsg":unauthorized,"result":[]} but server not return anything, since not take id , password authentication, rather needs base64 encoding header. can please tell me how achieve this?
thanks in advance.
the python requests library allow add custom headers. should able create appropriate header (with base64 encoding) , pass parameter, so:
import requests url = 'https://test.com/test-api-gateway/v0/deployments' myheaders = {'my-header-param': 'somedata'} r = requests.get(url, headers=myheaders, verify=false)).text the related documentation can found here.
Comments
Post a Comment