/// <summary> /// Remove a user from token cache. /// </summary> /// <param name="account"></param> /// <param name="tokenCache">This parameter is no longer used. However to keep the API unchanged it's not removed.</param> public void RemoveUser(IAzureAccount account, IAzureTokenCache tokenCache) { if (account != null && !string.IsNullOrEmpty(account.Id) && !string.IsNullOrWhiteSpace(account.Type)) { switch (account.Type) { case AzureAccount.AccountType.AccessToken: account.SetProperty(AzureAccount.Property.AccessToken, null); account.SetProperty(AzureAccount.Property.GraphAccessToken, null); account.SetProperty(AzureAccount.Property.KeyVaultAccessToken, null); break; case AzureAccount.AccountType.ManagedService: account.SetProperty(AzureAccount.Property.MSILoginUri, null); break; case AzureAccount.AccountType.ServicePrincipal: try { KeyStore.DeleteKey(account.Id, account.GetTenants().FirstOrDefault()); } catch { // make best effort to remove credentials } RemoveFromTokenCache(account); break; case AzureAccount.AccountType.User: RemoveFromTokenCache(account); break; } } }