Skip to content

Commit b4401a1

Browse files
committed
Use throttled_http_client
1 parent e33b055 commit b4401a1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

msal/application.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .token_cache import TokenCache
2222
import msal.telemetry
2323
from .region import _detect_region
24+
from .throttled_http_client import ThrottledHttpClient
2425

2526

2627
# The __init__.py will import this. Not the other way around.
@@ -336,6 +337,10 @@ def __init__(
336337
a = requests.adapters.HTTPAdapter(max_retries=1)
337338
self.http_client.mount("http://", a)
338339
self.http_client.mount("https://", a)
340+
self.http_client = ThrottledHttpClient(
341+
self.http_client,
342+
{} # Hard code an in-memory cache, for now
343+
)
339344

340345
self.app_name = app_name
341346
self.app_version = app_version
@@ -433,6 +438,7 @@ def _build_client(self, client_credential, authority, skip_regional_client=False
433438
"x-client-sku": "MSAL.Python", "x-client-ver": __version__,
434439
"x-client-os": sys.platform,
435440
"x-client-cpu": "x64" if sys.maxsize > 2 ** 32 else "x86",
441+
"x-ms-lib-capability": "retry-after, h429",
436442
}
437443
if self.app_name:
438444
default_headers['x-app-name'] = self.app_name

0 commit comments

Comments
 (0)