Skip to content

Commit faf07de

Browse files
Copilotgladjohn
andcommitted
Fix 5 CodeQL clear-text logging alerts in sample/msi_v2_sample.py
Co-authored-by: gladjohn <90415114+gladjohn@users.noreply.github.com>
1 parent 7d08bba commit faf07de

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

sample/msi_v2_sample.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8174
if __name__ == "__main__":

0 commit comments

Comments
 (0)