我的命令:python3 -mzeep https://pearson:m0bApP5@cms.powerschool.com/pearson-rest/services/PublicPortalServiceJSON?wsdl
我收到错误:
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://pearson:m0bApP5@cms.powerschool.com/pearson-rest/services/PublicPortalServiceJSON?wsdl
转到https://cms.powerschool.com/pearson-rest/services/PublicPortalServiceJSON?wsdl
并使用pearson和m0bApP5手动验证,但为什么不这样做?
我也试过使用这段代码,但它也没用。
#!/usr/bin/env python3
from zeep import Client
from requests.auth import HTTPBasicAuth # or HTTPDigestAuth, or OAuth1, etc.
from requests import Session
from zeep.transports import Transport
session = Session()
session.auth = HTTPBasicAuth("pearson","m0bApP5")
url = "https://cms.powerschool.com/pearson-rest/services/PublicPortalServiceJSON?wsdl"
stransport = Transport(session=session)
client = Client(url,transport=stransport)
client.wsdl.dump()
答案 0 :(得分:0)
您应该像这样使用 HTTPDigestAuth:
session = requests.session()
session.auth = requests.auth.HTTPDigestAuth(api_username, api_password)
self.url = base_url + "pearson-rest/services/PublicPortalServiceJSON"
try:
self.client = zeep.Client(
wsdl=self.url + "?wsdl",
transport=zeep.transports.Transport(session=session),
)
except requests.exceptions.ConnectionError:
raise APIException(f"Could not connect to {base_url}.")
except requests.exceptions.HTTPError:
raise APIException(
f"Incorrect api credentials ({api_username}, {api_password})."
)