Azure-Samples / Azure-Samples/ms-identity-python-daemon

Close key file after reading in Python example

Open
#23 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PowerShell
Stars
62
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Don't open a file in Python without closing it. This code is bad mojo:
```
app = msal.ConfidentialClientApplication(
config["client_id"], authority=config["authority"],
client_credential={"thumbprint": config["thumbprint"], "private_key": open(config['private_key_file']).read()},
)
```
Prefer:
```
with open(config['private_key_file']) as f:
key = f.read()
app = msal.ConfidentialClientApplication(
config["client_id"], authority=config["authority"],
client_credential={"thumbprint": config["thumbprint"], "private_key": key },
)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.