예제 #1
0
        public static IConfidentialClientApplication BuildConfidentialClientApplication()
        {
            IConfidentialClientApplication clientapp = ConfidentialClientApplicationBuilder.Create(Globals.ClientId)
                                                       .WithClientSecret(Globals.ClientSecret)
                                                       .WithRedirectUri(Globals.RedirectUri)
                                                       .WithAuthority(new Uri(Globals.Authority))
                                                       .Build();

            MSALPerUserMemoryTokenCache userTokenCache = new MSALPerUserMemoryTokenCache(clientapp.UserTokenCache);

            return(clientapp);
        }
예제 #2
0
        public static void ClearUserTokenCache()
        {
            IConfidentialClientApplication clientapp = ConfidentialClientApplicationBuilder.Create(Globals.ClientId)
                                                       .WithClientSecret(Globals.ClientSecret)
                                                       .WithRedirectUri(Globals.RedirectUri)
                                                       .WithAuthority(new Uri(string.Format(Globals.Authority, Globals.TenantId)))
                                                       .Build();

            // We only clear the user's tokens.
            MSALPerUserMemoryTokenCache userTokenCache = new MSALPerUserMemoryTokenCache(clientapp.UserTokenCache);

            userTokenCache.Clear();
        }