A Microsoft platform for building and publishing apps for Windows devices.
Hi @Hong ,
Thanks for reaching out.
From the stack trace, this looks less like your app code suddenly breaking and more like the authentication flow underneath it no longer returning what WindowsProvider expects. The failure is happening inside WindowsProvider.GetTokenAsync(), so the likely issue is that the Windows account broker is returning an unexpected or incomplete token result, and the Toolkit ends up hitting a null reference while processing it.
The first thing I would try is turning off the automatic silent sign-in in the constructor and handling the flow explicitly. WindowsProvider defaults autoSignIn to true, so it may already be kicking off a silent sign-in before your later SignInAsync() call runs. Driving that flow yourself is the cleanest short-term test and may avoid the overlap entirely:
string[] scopes = { "Files.ReadWrite.AppFolder" };
var provider = new WindowsProvider(scopes, autoSignIn: false);
ProviderManager.Instance.GlobalProvider = provider;
if (!await provider.TrySilentSignInAsync())
{
await provider.SignInAsync();
}
That sample is mainly meant as a reference for the sign-in flow, so you may need to adjust it a bit to fit your app structure and how your project initializes authentication.
If that still fails, I would clear any cached account state next. This provider stores account information in local app settings, and if those cached values no longer line up with what Windows account services expect, sign-in can start failing even though the code has not changed. Clearing the app's local data, reinstalling the app, or removing and re-adding the Microsoft account under Windows account settings are all good checks. It is also worth trying the same build on a different Windows profile or another machine. If it only fails on one profile, that points much more strongly to stale local account or token state than to a regression in your app.
One other thing to verify is that the provider is being created and used on a UI-capable thread. The interactive path uses AccountsSettingsPane, so if this is now being called from a different context than before, passing the correct DispatcherQueue into WindowsProvider is important.
If you want to narrow down the culprit more precisely, try logging the full exception details and, if possible, step into the Toolkit source around GetTokenAsync(). If the token request is coming back as successful but the response payload is null or empty, that would confirm this is really an edge case between the Toolkit and the Windows broker rather than a normal sign-in error in your app.
For the longer term, I would also keep in mind that CommunityToolkit.Authentication.Uwp is an older authentication stack and is not especially resilient to changes in the identity platform. If this app is still being maintained, moving the sign-in flow to MSAL with Microsoft Graph would be the more reliable path going forward, and it will also give you much better diagnostics when token acquisition fails.
Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.