GraphServiceClient token cache persistence and CAE control
@ramsessanchez ci sta già lavorando.
Dal 18/5/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Is your feature request related to a problem? Please describe the problem.
As outlined in this issue: https://github.com/Azure/azure-sdk-for-python/issues/42898
Given this example code:
token_cache_options = TokenCachePersistenceOptions(name="MyApp")
if Path("cred.json").exists():
with open("cred.json", "r") as f:
deserealized_record = AuthenticationRecord.deserialize(f.read())
device_credential = DeviceCodeCredential(
client_id=azure_settings["clientId"],
tenant_id=azure_settings["tenantId"],
authentication_record=deserealized_record,
cache_persistence_options=token_cache_options,
disable_automatic_authentication=True,
)
else:
device_credential = DeviceCodeCredential(
client_id=azure_settings["clientId"],
tenant_id=azure_settings["tenantId"],
cache_persistence_options=token_cache_options,
disable_automatic_authentication=True,
)
record = device_credential.authenticate(scopes=azure_settings["graphScope"])
with open("cred.json", "w") as f:
f.write(record.serialize())
app_client = GraphServiceClient(
credentials=device_credential, scopes=azure_settings["graphScope"]
)
# do something with app_client, eg: `app_client.me.get()`
We will not be able to achieve token cache persistence, because by default, the AzureIdentityAuthenticationProvider used internally by the GraphServiceClient has it's CAE setting set to True while the DeviceCodeCredential.authenticate method defaults it to False. Setting the value in authenticate explicitly to True makes the code work:
record = device_credential.authenticate(scopes=azure_settings["graphScope"], enable_cae=True)
But this leaves one issue - if (for some reason) someone wants to set the above value to False, they will never be able to make the code work using the current implementation of the GraphServiceClient.
Describe the solution you'd like.
It is my suggestion to add an argument to the GraphServiceClient initializer method to allow controlling the is_cae_enabled parameter of the AzureIdentityAuthenticationProvider object created inside.
Additional context?
No response
- Lingua principale
- Python
- Stelle
- 630
- Fork
- 96
- Merge medio
- 15h 20m
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-python
-
status:waiting-for-triage type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
-
status:waiting-for-triage type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoftgraph/msgraph-sdk-python#1563 ·
-
Needs: Attention :wave: type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoftgraph/msgraph-sdk-python#1287 · 2 commenti · 1 reazione ·
-
Batch Request Support Apertastatus:waiting-for-triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
microsoftgraph/msgraph-sdk-python#1557 ·
-
status:waiting-for-triage type:bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
microsoftgraph/msgraph-sdk-python#1556 · 1 commento · 1 reazione ·
Tutte le issue di microsoftgraph/msgraph-sdk-python
Issue simili
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100