TokenCache Class

This is considered as a base class containing minimal cache behavior.

Although it maintains tokens using unified schema across all MSAL libraries, this class does not serialize/persist them. See subclass SerializableTokenCache for details on serialization.

Inheritance
builtins.object
TokenCache

Constructor

TokenCache()

Methods

add

Handle a token obtaining event, and add tokens into cache.

find

Equivalent to list(search(...)).

modify
remove_account
remove_at
remove_idt
remove_rt
search

Returns a generator of matching entries.

It is O(1) for AT hits, and O(n) for other types. Note that it holds a lock during the entire search.

update_rt

add

Handle a token obtaining event, and add tokens into cache.

add(event, now=None)

Parameters

Name Description
event
Required
now
Default value: None

find

Equivalent to list(search(...)).

find(credential_type, target=None, query=None)

Parameters

Name Description
credential_type
Required
target
Default value: None
query
Default value: None

modify

modify(credential_type, old_entry, new_key_value_pairs=None)

Parameters

Name Description
credential_type
Required
old_entry
Required
new_key_value_pairs
Default value: None

remove_account

remove_account(account_item)

Parameters

Name Description
account_item
Required

remove_at

remove_at(at_item)

Parameters

Name Description
at_item
Required

remove_idt

remove_idt(idt_item)

Parameters

Name Description
idt_item
Required

remove_rt

remove_rt(rt_item)

Parameters

Name Description
rt_item
Required

Returns a generator of matching entries.

It is O(1) for AT hits, and O(n) for other types. Note that it holds a lock during the entire search.

search(credential_type, target=None, query=None)

Parameters

Name Description
credential_type
Required
target
Default value: None
query
Default value: None

update_rt

update_rt(rt_item, new_rt)

Parameters

Name Description
rt_item
Required
new_rt
Required