55 from urlparse import urlparse
66import logging
77
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-
138from .exceptions import MsalServiceError
149
1510
@@ -59,9 +54,10 @@ class Authority(object):
5954 _domains_without_user_realm_discovery = set ([])
6055
6156 @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
6561
6662 def __init__ (self , authority_url , http_client , validate_authority = True ):
6763 """Creates an authority instance, and also validates it.
@@ -84,7 +80,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
8480 payload = instance_discovery (
8581 "https://{}{}/oauth2/v2.0/authorize" .format (
8682 self .instance , authority .path ),
87- self .http_client )
83+ self ._http_client )
8884 if payload .get ("error" ) == "invalid_instance" :
8985 raise ValueError (
9086 "invalid_instance: "
@@ -104,7 +100,7 @@ def __init__(self, authority_url, http_client, validate_authority=True):
104100 try :
105101 openid_config = tenant_discovery (
106102 tenant_discovery_endpoint ,
107- self .http_client )
103+ self ._http_client )
108104 except ValueError :
109105 raise ValueError (
110106 "Unable to get authority configuration for {}. "
@@ -124,7 +120,7 @@ def user_realm_discovery(self, username, correlation_id=None, response=None):
124120 # "federation_protocol", "cloud_audience_urn",
125121 # "federation_metadata_url", "federation_active_auth_url", etc.
126122 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 (
128124 "https://{netloc}/common/userrealm/{username}?api-version=1.0" .format (
129125 netloc = self .instance , username = username ),
130126 headers = {'Accept' : 'application/json' ,
0 commit comments