'MSAL.Net After removing IAccounts from token cache can no longer get Id token

In my xamarin.forms mobile app using AD B2C I cleared the IAccounts as a way to "log out" and since then all attempts to aquire token return access token but no Id token.

I "log out" using following code;

public async Task<UserContext> SignOutAsync()
    {
        IEnumerable<IAccount> accounts = await _pca.GetAccountsAsync();
        while (accounts.Any())
        {
            await _pca.RemoveAsync(accounts.FirstOrDefault());
            accounts = await _pca.GetAccountsAsync();
        }
        var signedOutContext = new UserContext
        {
            IsLoggedOn = false
        };
        return signedOutContext;
    }

now when the app calls AcquireTokenInteractive the Microsoft.Identity.Cient AuthenticationResult in PublicClientApplication contains no Id Token. The code is;

        private async Task<UserContext> SignInInteractively()
    {

        AuthenticationResult authResult = await _pca.AcquireTokenInteractive(B2CConstants.Scopes)
            .WithUseEmbeddedWebView(true)
            .ExecuteAsync();

        var newContext = UpdateUserInfo(authResult);
        return newContext;
    }

Appreciate any advice as to what to look into. Could it be how I have configured the Azure AAD apps or an issue with client code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source