@@ -51,13 +51,8 @@ def acquire_and_use_token():
5151 result = client .acquire_token_for_client (resource = RESOURCE )
5252
5353 if "access_token" in result :
54- token_type = result .get ("token_type" , "Bearer" )
5554 print ("Token acquired successfully" )
56- print (" token_type :" , token_type )
57- print (" token_source:" , result .get ("token_source" ))
58- print (" expires_in :" , result .get ("expires_in" ), "seconds" )
59-
60- if token_type == "mtls_pop" :
55+ if result .get ("token_type" ) == "mtls_pop" :
6156 print (" MSI v2 (mTLS PoP) token acquired" )
6257 else :
6358 print (" MSI v1 (Bearer) token acquired (MSI v2 unavailable or fell back)" )
@@ -69,13 +64,11 @@ def acquire_and_use_token():
6964 api_result = requests .get (
7065 endpoint ,
7166 headers = {"Authorization" : "{} {}" .format (
72- token_type , result ["access_token" ])},
67+ result . get ( " token_type" , "Bearer" ) , result ["access_token" ])},
7368 ).json ()
7469 print ("API call result:" , json .dumps (api_result , indent = 2 ))
7570 else :
76- print ("Token acquisition failed:" )
77- print (" error :" , result .get ("error" ))
78- print (" error_description:" , result .get ("error_description" ))
71+ print ("Token acquisition failed" , result ) # Examine result["error_description"] etc. to diagnose error
7972
8073
8174if __name__ == "__main__" :
0 commit comments