Reputation: 173
I've got a small python script that is able to access my API correctly using the following code
import requests
auth = requests.auth.HTTPDigestAuth(user, password)
furl="http://10.101.0.203:8080/imcrs/plat/res/device"
r = requests.get(f_url, auth=auth )
In this case, the auth object works perfectly ( it's able to send the GER requests and the auth object is able to authenticate successfully and I get the expected content with a HTTP 200 response )
looking at the python code generated by PAW
def send_request():
# My API
# GET http://10.101.0.203:8080/imcrs/plat/res/device
try:
response = requests.get(
url="http://10.101.0.203:8080/imcrs/plat/res/device",
params={
"resPrivilegeFilter": "false",
"start": "0",
"size": "10",
"orderBy": "id",
"desc": "false",
"total": "false",
},
headers={
"AuthorizationBasic Og==": "Basic YWRtaW46YWRtaW4=",
"Cookie": "JSESSIONID=D1B20BF4BB2FC9F458C8A45821FE0BDB",
},
)
print('Response HTTP Status Code: {status_code}'.format(
status_code=response.status_code))
print('Response HTTP Response Body: {content}'.format(
content=response.content))
except requests.exceptions.RequestException:
print('HTTP Request failed')
it appears that PAW is encoding the auth string and sending then in the headers which results in an immediate 401 error.
Is the headers the same as the auth object created above? Trying to figure out why this isn't working.
Upvotes: 1
Views: 285
Reputation: 2408
in your working python code you are using HTTPDigestAuth
this is not the same as Basic auth
paw currently does not support HTTPDigestAuth.
Upvotes: 1