AcquireTokenSilent always Failed to acquire token silently

后端 未结 5 670
清酒与你
清酒与你 2021-01-04 04:16

Using ADAL I have two AuthenticationContext using a Token Cache persisted in SQL.

Using AcquireTokenByAuthorizationCode it writes the Token

5条回答
  •  温柔的废话
    2021-01-04 04:55

    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);
                        }
    

提交回复
热议问题