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
@@ -59,9 +54,10 @@ class Authority(object):
59
54
_domains_without_user_realm_discovery = set ([])
60
55
61
56
@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
57
+ def http_client (self ): # Obsolete. We will remove this eventually
58
+ warnings .warn (
59
+ "authority.http_client might be removed in MSAL Python 1.21+" , DeprecationWarning )
60
+ return self ._http_client
65
61
66
62
def __init__ (self , authority_url , http_client , validate_authority = True ):
67
63
"""Creates an authority instance, and also validates it.
@@ -84,7 +80,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
84
80
payload = instance_discovery (
85
81
"https://{}{}/oauth2/v2.0/authorize" .format (
86
82
self .instance , authority .path ),
87
- self .http_client )
83
+ self ._http_client )
88
84
if payload .get ("error" ) == "invalid_instance" :
89
85
raise ValueError (
90
86
"invalid_instance: "
@@ -104,7 +100,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
104
100
try :
105
101
openid_config = tenant_discovery (
106
102
tenant_discovery_endpoint ,
107
- self .http_client )
103
+ self ._http_client )
108
104
except ValueError :
109
105
raise ValueError (
110
106
"Unable to get authority configuration for {}. "
@@ -124,7 +120,7 @@ def user_realm_discovery(self, username, correlation_id=None, response=None):
124
120
# "federation_protocol", "cloud_audience_urn",
125
121
# "federation_metadata_url", "federation_active_auth_url", etc.
126
122
if self .instance not in self .__class__ ._domains_without_user_realm_discovery :
127
- resp = response or self .http_client .get (
123
+ resp = response or self ._http_client .get (
128
124
"https://{netloc}/common/userrealm/{username}?api-version=1.0" .format (
129
125
netloc = self .instance , username = username ),
130
126
headers = {'Accept' : 'application/json' ,
0 commit comments