Using ADAL I have two AuthenticationContext
using a Token Cache persisted in SQL.
Using AcquireTokenByAuthorizationCode
it writes the Token
Check if token is existing in cache else sign out and ask user to sign in.
AuthenticationContext authContext = new AuthenticationContext(Startup.Authority,
new NaiveSessionCache(userObjectID));
if (authContext.TokenCache.Count == 0)
{
authContext.TokenCache.Clear();
CosmosInterface.Utils.AuthenticationHelper.token = null;
HttpContext.GetOwinContext().Authentication.SignOut(
OpenIdConnectAuthenticationDefaults.AuthenticationType,
CookieAuthenticationDefaults.AuthenticationType);
}