5
5
from urlparse import urlparse
6
6
import logging
7
7
8
- # Historically some customers patched this module-wide requests instance.
9
- # We keep it here for now. They will be removed in next major release.
10
- import requests
11
- import requests as _requests
12
-
13
8
from .exceptions import MsalServiceError
14
9
15
10
@@ -58,11 +53,6 @@ class Authority(object):
58
53
"""
59
54
_domains_without_user_realm_discovery = set ([])
60
55
61
- @property
62
- def http_client (self ): # Obsolete. We will remove this in next major release.
63
- # A workaround: if module-wide requests is patched, we honor it.
64
- return self ._http_client if requests is _requests else requests
65
-
66
56
def __init__ (self , authority_url , http_client , validate_authority = True ):
67
57
"""Creates an authority instance, and also validates it.
68
58
@@ -84,7 +74,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
84
74
payload = instance_discovery (
85
75
"https://{}{}/oauth2/v2.0/authorize" .format (
86
76
self .instance , authority .path ),
87
- self .http_client )
77
+ self ._http_client )
88
78
if payload .get ("error" ) == "invalid_instance" :
89
79
raise ValueError (
90
80
"invalid_instance: "
@@ -104,7 +94,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
104
94
try :
105
95
openid_config = tenant_discovery (
106
96
tenant_discovery_endpoint ,
107
- self .http_client )
97
+ self ._http_client )
108
98
except ValueError :
109
99
raise ValueError (
110
100
"Unable to get authority configuration for {}. "
@@ -124,7 +114,7 @@ def user_realm_discovery(self, username, correlation_id=None, response=None):
124
114
# "federation_protocol", "cloud_audience_urn",
125
115
# "federation_metadata_url", "federation_active_auth_url", etc.
126
116
if self .instance not in self .__class__ ._domains_without_user_realm_discovery :
127
- resp = response or self .http_client .get (
117
+ resp = response or self ._http_client .get (
128
118
"https://{netloc}/common/userrealm/{username}?api-version=1.0" .format (
129
119
netloc = self .instance , username = username ),
130
120
headers = {'Accept' : 'application/json' ,
0 commit comments