I am trying to integrate WS-Federation in my Asp.Net MVC app using OWIN. I followed the github samples and it is working as expected.
Now I want to take this one step further and call an external WebApi hosted on different Azure web app from within my website. I couldn't find any WS-Fed samples for this scenario. WebApi needs an access token to provide access to protected resources. In one of my MVC controllers I tried using ADAL.Net code to acquire the access token but i get timeout error.
string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
var authContext1 = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority, new NaiveSessionCache(userObjectID));
var credential = new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential(clientId, appKey);
var tokenResult = await authContext1.AcquireTokenAsync(todoListResourceId, credential);
I copied NaiveSessionCache from one of the azure samples on github. Then I pass this tokenResult.AccessToken to webApi call using HttpClient. This gives me 500 server timeout error.
However, if I don't use NaiveSessionCache in authContext1 and replace it with false in its constructor (no cache), code works fine.
What am I missing here? Thanks!