Open ArthurKamalov opened 7 months ago
Observations: It seems that the InteractiveBrowserCredential is able to save its token to persistent cache storage, but it is not able to use that cache later. ( It actually has its own method _acquire_token_silent, but, as far as I can see, it does not check for token in cache, but already expects an instance of the AuthenticationRecord class, which, I assume, we have to handle and store manually) That's why I also made an assumtion that we should use SharedTokenCacheCredential for that. I know that the SharedTokenCacheCredential was previously removed by @vxfield and there might be a valid reason for that, but I haven't found any better workaround, so I would glad to hear whether we can use it or not.
The _auth_record
is automatically set upon successful Browser Authentication source.
We don't need to worry about it if we also use the SharedTokenCacheCredential
as you said to use the cache on a different process or instantiation of our SDK.
@ArthurKamalov, @kikomiss: I'll hand this back to you now.
I think the next steps would be to add test cases for the _DefaultAzureCredential.get_token()
method with different authentication scenarios.
See how we instantiate the _DefaultAzureCredential
here.
These new test cases:
test_authentication.py
file.get_token()
method of each credential that we support and check if _DefaultAzureCredential.get_token()
is returning that token._get_persistence
function to raise an Exception and check if a Warning is emitted during the _get_cache_options()
method, and that it still returns the mocked InteractiveBrowserCredential
token.
The original problem: the
InteractiveBrowserCredential
required login by browser on each new run.Observations: It seems that the
InteractiveBrowserCredential
is able to save its token to persistent cache storage, but it is not able to use that cache later. ( It actually has its own method _acquire_token_silent, but, as far as I can see, it does not check for token in cache, but already expects an instance of the AuthenticationRecord class, which, I assume, we have to handle and store manually) That's why I also made an assumtion that we should useSharedTokenCacheCredential
for that. I know that theSharedTokenCacheCredential
was previously removed by @vxfield and there might be a valid reason for that, but I haven't found any better workaround, so I would glad to hear whether we can use it or not.