AcquireTokenSilent() fails

503 Views Asked by At

I am writing a WinForms client which is connecting to an azure WebAPI.

the program fails to call AcquireTokenSilent with a specific account. I always get this message:

"You are trying to acquire a token silently using a login hint. No account was found in the token cache having this login hint."

However, a call of AcquireTokenInteractive with the same account works.

Here is the preparation:

IPublicClientApplication pca = PublicClientApplicationBuilder
        .Create(ClientID)
        .WithAuthority(AzureCloudInstance.AzurePublic, TenantID)
        .WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
        .Build();
string[] scopes = { "user.read" };

AuthenticationResult result;

Now this part fails:

result = await pca.AcquireTokenSilent(scopes, "[email protected]").ExecuteAsync();

However, this part works:

The interactive dialog is showing me the same account as above, "[email protected]".

result = await pca.AcquireTokenInteractive(scopes).ExecuteAsync();
0

There are 0 best solutions below