@@ -33,6 +33,17 @@ def encode_saml_assertion(assertion):
3333 CLIENT_ASSERTION_TYPE_SAML2 = "urn:ietf:params:oauth:client-assertion-type:saml2-bearer"
3434 client_assertion_encoders = {CLIENT_ASSERTION_TYPE_SAML2 : encode_saml_assertion }
3535
36+ @property
37+ def session (self ):
38+ warnings .warn ("Will be gone in next major release" , DeprecationWarning )
39+ return self ._http_client
40+
41+ @session .setter
42+ def session (self , value ):
43+ warnings .warn ("Will be gone in next major release" , DeprecationWarning )
44+ self ._http_client = value
45+
46+
3647 def __init__ (
3748 self ,
3849 server_configuration , # type: dict
@@ -132,14 +143,14 @@ def __init__(
132143 raise ValueError (
133144 "verify, proxies, or timeout is not allowed "
134145 "when http_client is in use" )
135- self .http_client = http_client
146+ self ._http_client = http_client
136147 else :
137- self .http_client = requests .Session ()
138- self .http_client .verify = True if verify is None else verify
139- self .http_client .proxies = proxies
140- self .http_client .request = functools .partial (
148+ self ._http_client = requests .Session ()
149+ self ._http_client .verify = True if verify is None else verify
150+ self ._http_client .proxies = proxies
151+ self ._http_client .request = functools .partial (
141152 # A workaround for requests not supporting session-wide timeout
142- self .http_client .request , timeout = timeout )
153+ self ._http_client .request , timeout = timeout )
143154
144155 def _build_auth_request_params (self , response_type , ** kwargs ):
145156 # response_type is a string defined in
@@ -200,7 +211,7 @@ def _obtain_token( # The verb "obtain" is influenced by OAUTH2 RFC 6749
200211
201212 if "token_endpoint" not in self .configuration :
202213 raise ValueError ("token_endpoint not found in configuration" )
203- resp = (post or self .http_client .post )(
214+ resp = (post or self ._http_client .post )(
204215 self .configuration ["token_endpoint" ],
205216 headers = _headers , params = params , data = _data ,
206217 ** kwargs )
@@ -269,7 +280,7 @@ def initiate_device_flow(self, scope=None, **kwargs):
269280 DAE = "device_authorization_endpoint"
270281 if not self .configuration .get (DAE ):
271282 raise ValueError ("You need to provide device authorization endpoint" )
272- resp = self .http_client .post (self .configuration [DAE ],
283+ resp = self ._http_client .post (self .configuration [DAE ],
273284 data = {"client_id" : self .client_id , "scope" : self ._stringify (scope or [])},
274285 headers = dict (self .default_headers , ** kwargs .pop ("headers" , {})),
275286 ** kwargs )
0 commit comments