Пример #1
0
        /// <summary>
        /// Clears all cached tokens obtained and cached for the app itself.
        /// If you have scenarios like on-behalf-of which results in the user token cache caching tokens for users as well, that'd be cleared up here as well
        /// </summary>
        private void RemovedCachedTokensForApp()
        {
            string tenantId = ClaimsPrincipal.Current?.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid")?.Value;

            if (string.IsNullOrEmpty(tenantId))
            {
                return;
            }

            IConfidentialClientApplication daemonClient;

            daemonClient = ConfidentialClientApplicationBuilder.Create(Startup.clientId)
                           .WithAuthority(string.Format(AuthorityFormat, tenantId))
                           .WithRedirectUri(Startup.redirectUri)
                           .WithClientSecret(Startup.clientSecret)
                           .Build();

            var serializedUserTokenCache = new MSALUserTokenMemoryCache(Startup.clientId, daemonClient.UserTokenCache);

            serializedUserTokenCache.Clear();
        }
Пример #2
0
    private void RemovedCachedTokensForApp()
    {
        string tenantId = ClaimsPrincipal.Current?.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid")?.Value;

        if (string.IsNullOrEmpty(tenantId))
        {
            return;
        }

        IConfidentialClientApplication daemonClient;

        daemonClient = ConfidentialClientApplicationBuilder.Create(TestSite.Startup.clientId)
                       .WithAuthority("http://login.microsoftonline.com/74179e4d-962e-4fdb-bd11-9803ffe026cb/oauth2/authorize")
                       .WithRedirectUri(TestSite.Startup.redirectUri)

                       .Build();

        var serializedUserTokenCache = new MSALUserTokenMemoryCache(TestSite.Startup.clientId, daemonClient.UserTokenCache);

        serializedUserTokenCache.Clear();
    }