MCPcopy Create free account
hub / github.com/AzureAD/microsoft-authentication-library-for-python / modify

Method modify

msal/token_cache.py:458–474  ·  view source on GitHub ↗
(self, credential_type, old_entry, new_key_value_pairs=None)

Source from the content-addressed store, hash-verified

456 self.modify(self.CredentialType.APP_METADATA, app_metadata, app_metadata)
457
458 def modify(self, credential_type, old_entry, new_key_value_pairs=None):
459 # Modify the specified old_entry with new_key_value_pairs,
460 # or remove the old_entry if the new_key_value_pairs is None.
461
462 # This helper exists to consolidate all token add/modify/remove behaviors,
463 # so that the sub-classes will have only one method to work on,
464 # instead of patching a pair of update_xx() and remove_xx() per type.
465 # You can monkeypatch self.key_makers to support more types on-the-fly.
466 key = self.key_makers[credential_type](**old_entry)
467 with self._lock:
468 if new_key_value_pairs: # Update with them
469 entries = self._cache.setdefault(credential_type, {})
470 entries[key] = dict(
471 old_entry, # Do not use entries[key] b/c it might not exist
472 **new_key_value_pairs)
473 else: # Remove old_entry
474 self._cache.setdefault(credential_type, {}).pop(key, None)
475
476 def remove_rt(self, rt_item):
477 assert rt_item.get("credential_type") == self.CredentialType.REFRESH_TOKEN

Callers 8

__addMethod · 0.95
remove_rtMethod · 0.95
update_rtMethod · 0.95
remove_atMethod · 0.95
remove_idtMethod · 0.95
remove_accountMethod · 0.95
modifyMethod · 0.45

Calls

no outgoing calls