Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while authenticating web app through Azure i recieved following error
C#
Failed to acquire token silently. Call method AcquireToken

my code


<pre lang="C#">string AccessToken = string.Empty;
           string userObjectID = ClaimsPrincipal.Current.FindFirst(&quot;http://schemas.microsoft.com/identity/claims/objectidentifier&quot;).Value;
           AuthenticationContext authContext = new AuthenticationContext(Authority, new NaiveSessionCache(userObjectID));
           ClientCredential credential = new ClientCredential(clientId, appKey);
           AuthenticationResult result = null;

          
           if ((HttpContext.Current.Session[&quot;AccessToken&quot;] == null &amp;&amp; HttpContext.Current.Session[&quot;RefreshToken&quot;] == null))
           {
               result = authContext.AcquireTokenSilent(todoListResourceId, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));
               AccessToken = result.AccessToken;
               HttpContext.Current.Session[&quot;AccessToken&quot;] = result.AccessToken;
               HttpContext.Current.Session[&quot;RefreshToken&quot;] = result.RefreshToken;</pre>




on this line i recieve error
result = authContext.AcquireTokenSilent(todoListResourceId, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));

What I have tried:

I have tried with multiple AAD Application instances,
looked for almost all solutions on google
Posted
Updated 18-Mar-16 1:40am
v2
Comments
AnvisNet 18-Mar-16 8:18am    
stack trace
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.RunAsyncTask[T](Task`1 task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.AcquireTokenSilent(String resource, ClientCredential clientCredential, UserIdentifier userId)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900