MCPcopy Create free account
hub / github.com/AzureAD/microsoft-authentication-library-for-python / send_request

Function send_request

msal/wstrust_request.py:37–60  ·  view source on GitHub ↗
(
        username, password, cloud_audience_urn, endpoint_address, soap_action, http_client,
        **kwargs)

Source from the content-addressed store, hash-verified

35logger = logging.getLogger(__name__)
36
37def send_request(
38 username, password, cloud_audience_urn, endpoint_address, soap_action, http_client,
39 **kwargs):
40 if not endpoint_address:
41 raise ValueError("WsTrust endpoint address can not be empty")
42 if soap_action is None:
43 if '/trust/2005/usernamemixed' in endpoint_address:
44 soap_action = Mex.ACTION_2005
45 elif '/trust/13/usernamemixed' in endpoint_address:
46 soap_action = Mex.ACTION_13
47 if soap_action not in (Mex.ACTION_13, Mex.ACTION_2005):
48 raise ValueError("Unsupported soap action: %s. "
49 "Contact your administrator to check your ADFS's MEX settings." % soap_action)
50 data = _build_rst(
51 username, password, cloud_audience_urn, endpoint_address, soap_action)
52 resp = http_client.post(endpoint_address, data=data, headers={
53 'Content-type':'application/soap+xml; charset=utf-8',
54 'SOAPAction': soap_action,
55 }, **kwargs)
56 if resp.status_code >= 400:
57 logger.debug("Unsuccessful WsTrust request receives: %s", resp.text)
58 # It turns out ADFS uses 5xx status code even with client-side incorrect password error
59 # resp.raise_for_status()
60 return parse_response(resp.text)
61
62
63def escape_xml(s):

Callers

nothing calls this directly

Calls 3

_build_rstFunction · 0.85
parse_responseFunction · 0.85
postMethod · 0.45

Tested by

no test coverage detected