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

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

Abierto
#30 0 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
PowerShell
Estrellas
62
Forks
27
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.