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

Samples: incorrect/misleading cached token lookup using `account=None`

Đang mở
#30 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PowerShell
Star
62
Fork
27
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

In the `1-Call-MsGraph-WithSecret` sample, the comments explain that calling `app.acquire_token_silent` will look up a token from cache ([source](https://github.com/Azure-Samples/ms-identity-python-daemon/blob/bbc488c40cc548dbfeef7c2178e8ee1b46abf8e3/1-Call-MsGraph-WithSecret/confidential_client_secret_sample.py#L53-L56)).
```python
# Firstly, looks up a token from cache
# Since we are looking for token for the current app, NOT for an end user,
# notice we give account parameter as None.
result = app.acquire_token_silent(config["scope"], account=None)
```

However, the current behavior of the acquire_token_silent function will immediately return None if the account parameter is provided as None as given in the sample ([source](https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/c1ead1caece73b81f7cb168ca22f8741504ec5bd/msal/application.py#L1284-L1285)).
```python
def acquire_token_silent(
self,
scopes, # type: List[str]
account, # type: Optional[Account]
...
if not account:
return None # A backward-compatible NO-OP to drop the account=None usage
```

Can the sample be updated to show how to properly retrieve a cached token?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.