Skip to content

Commit

Permalink
Switch to MSAL 1.29+'s TokenCache.search()
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed Jun 23, 2024
1 parent a0713c4 commit 6fd4920
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion msal_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Provides auxiliary functionality to the `msal` package."""
__version__ = "1.2.0b1" # Note: During/after release, copy this number to Dockerfile
__version__ = "1.2.0" # Note: During/after release, copy this number to Dockerfile

from .persistence import (
FilePersistence,
Expand Down
4 changes: 2 additions & 2 deletions msal_extensions/token_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def modify(self, credential_type, old_entry, new_key_value_pairs=None):
self._persistence.save(self.serialize())
self._last_sync = time.time()

def _find(self, credential_type, **kwargs): # pylint: disable=arguments-differ
def search(self, credential_type, **kwargs): # pylint: disable=arguments-differ
# Use optimistic locking rather than CrossPlatLock(self._lock_location)
retry = 3
for attempt in range(1, retry + 1):
Expand All @@ -83,6 +83,6 @@ def _find(self, credential_type, **kwargs): # pylint: disable=arguments-differ
else:
raise # End of retry. Re-raise the exception as-is.
else: # If reload encountered no error, the data is considered intact
return super(PersistedTokenCache, self)._find(credential_type, **kwargs)
return super(PersistedTokenCache, self).search(credential_type, **kwargs)
return [] # Not really reachable here. Just to keep pylint happy.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package_data={'': ['LICENSE']},
python_requires=">=3.7",
install_requires=[
'msal>=1.27,<1.29', # MSAL Python 1.29+ may not have TokenCache._find()
'msal>=1.29,<2', # Use TokenCache.search() from MSAL Python 1.29+
'portalocker<3,>=1.4',

## We choose to NOT define a hard dependency on this.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_agnostic_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _test_token_cache_roundtrip(persistence):
assert token2["token_source"] == "cache", "App2 should hit cache written by app1"
assert token1['access_token'] == token2['access_token'], "Cache should hit"

def test_token_cache_roundtrip_with_persistence_biulder(temp_location):
def test_token_cache_roundtrip_with_persistence_builder(temp_location):
_test_token_cache_roundtrip(build_encrypted_persistence(temp_location))

def test_token_cache_roundtrip_with_file_persistence(temp_location):
Expand Down

0 comments on commit 6fd4920

Please sign in to comment.