Description
If you have your home directory on Windows set to be the root of a drive, e.g. HOME=H:\
, then the token cache persistence fails with an EACCES
permissions error:
File "lib\site-packages\msal_extensions\token_cache.py", line 75, in __init__
FilePersistenceWithDataProtection(cache_location, entropy=entropy))
File "lib\site-packages\msal_extensions\persistence.py", line 159, in __init__
super(FilePersistenceWithDataProtection, self).__init__(location)
File "lib\site-packages\msal_extensions\persistence.py", line 103, in __init__
_mkdir_p(os.path.dirname(self._location))
File "lib\site-packages\msal_extensions\persistence.py", line 40, in _mkdir_p
os.makedirs(path)
File "lib\os.py", line 223, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'H:\\'
The simplest/best solution would be to update the persistence._mkdir_p()
implementation to look like this instead:
def _mkdir_p(path):
if path:
os.makedirs(path, exist_ok=True)
However, this requires Python ≥3.2. Considering that Python 2 was EOL at the start of 2020, this seems reasonable to me! Clearly, you might not wish to do so just for such a relatively small issue.
Alternatively, either the code could call the above only if Python is new enough (and so the bug persists under Python 2) or else it would presumably be necessary to implement roughly the same bug fix as they did in Python some years ago: https://bugs.python.org/issue25583
Metadata
Metadata
Assignees
Type
Projects
Status