AcquireTokenSilent() fails

Viewed 230

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, "office@mydomain.com").ExecuteAsync();

However, this part works:

The interactive dialog is showing me the same account as above, "office@mydomain.com".

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