1818from .wstrust_request import send_request as wst_send_request
1919from .wstrust_response import *
2020from .token_cache import TokenCache
21- import msal . telemetry
21+ from . import telemetry
2222
2323
2424# The __init__.py will import this. Not the other way around.
@@ -251,7 +251,7 @@ def __init__(
251251
252252 def _build_telemetry_context (
253253 self , api_id , correlation_id = None , refresh_reason = None ):
254- return msal . telemetry ._TelemetryContext (
254+ return telemetry ._TelemetryContext (
255255 self ._telemetry_buffer , self ._telemetry_lock , api_id ,
256256 correlation_id = correlation_id , refresh_reason = refresh_reason )
257257
@@ -777,7 +777,7 @@ def acquire_token_silent_with_error(
777777 """
778778 assert isinstance (scopes , list ), "Invalid parameter type"
779779 self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
780- correlation_id = msal . telemetry ._get_new_correlation_id ()
780+ correlation_id = telemetry ._get_new_correlation_id ()
781781 if authority :
782782 warnings .warn ("We haven't decided how/if this method will accept authority parameter" )
783783 # the_authority = Authority(
@@ -848,11 +848,11 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
848848 target = scopes ,
849849 query = query )
850850 now = time .time ()
851- refresh_reason = msal . telemetry .AT_ABSENT
851+ refresh_reason = telemetry .AT_ABSENT
852852 for entry in matches :
853853 expires_in = int (entry ["expires_on" ]) - now
854854 if expires_in < 5 * 60 : # Then consider it expired
855- refresh_reason = msal . telemetry .AT_EXPIRED
855+ refresh_reason = telemetry .AT_EXPIRED
856856 continue # Removal is not necessary, it will be overwritten
857857 logger .debug ("Cache hit an AT" )
858858 access_token_from_cache = { # Mimic a real response
@@ -861,12 +861,12 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
861861 "expires_in" : int (expires_in ), # OAuth2 specs defines it as int
862862 }
863863 if "refresh_on" in entry and int (entry ["refresh_on" ]) < now : # aging
864- refresh_reason = msal . telemetry .AT_AGING
864+ refresh_reason = telemetry .AT_AGING
865865 break # With a fallback in hand, we break here to go refresh
866866 self ._build_telemetry_context (- 1 ).hit_an_access_token ()
867867 return access_token_from_cache # It is still good as new
868868 else :
869- refresh_reason = msal . telemetry .FORCE_REFRESH # TODO: It could also mean claims_challenge
869+ refresh_reason = telemetry .FORCE_REFRESH # TODO: It could also mean claims_challenge
870870 assert refresh_reason , "It should have been established at this point"
871871 try :
872872 result = _clean_up (self ._acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family (
@@ -1013,7 +1013,7 @@ def acquire_token_by_refresh_token(self, refresh_token, scopes, **kwargs):
10131013 self ._validate_ssh_cert_input_data (kwargs .get ("data" , {}))
10141014 telemetry_context = self ._build_telemetry_context (
10151015 self .ACQUIRE_TOKEN_BY_REFRESH_TOKEN ,
1016- refresh_reason = msal . telemetry .FORCE_REFRESH )
1016+ refresh_reason = telemetry .FORCE_REFRESH )
10171017 response = _clean_up (self .client .obtain_token_by_refresh_token (
10181018 refresh_token ,
10191019 scope = decorate_scope (scopes , self .client_id ),
@@ -1131,10 +1131,10 @@ def initiate_device_flow(self, scopes=None, **kwargs):
11311131 - A successful response would contain "user_code" key, among others
11321132 - an error response would contain some other readable key/value pairs.
11331133 """
1134- correlation_id = msal . telemetry ._get_new_correlation_id ()
1134+ correlation_id = telemetry ._get_new_correlation_id ()
11351135 flow = self .client .initiate_device_flow (
11361136 scope = decorate_scope (scopes or [], self .client_id ),
1137- headers = {msal . telemetry .CLIENT_REQUEST_ID : correlation_id },
1137+ headers = {telemetry .CLIENT_REQUEST_ID : correlation_id },
11381138 ** kwargs )
11391139 flow [self .DEVICE_FLOW_CORRELATION_ID ] = correlation_id
11401140 return flow
@@ -1208,7 +1208,7 @@ def acquire_token_by_username_password(
12081208 self ._client_capabilities , claims_challenge ))
12091209 if not self .authority .is_adfs :
12101210 user_realm_result = self .authority .user_realm_discovery (
1211- username , correlation_id = headers [msal . telemetry .CLIENT_REQUEST_ID ])
1211+ username , correlation_id = headers [telemetry .CLIENT_REQUEST_ID ])
12121212 if user_realm_result .get ("account_type" ) == "Federated" :
12131213 response = _clean_up (self ._acquire_token_by_username_password_federated (
12141214 user_realm_result , username , password , scopes = scopes ,
0 commit comments