我使用Azure Azure Active Directory来保护我的Web API,并在Azure管理门户中创建本机应用程序.这个本机应用程序基本上是一个MVC Web应用程序,我使用ADAL库获取令牌并使用该令牌调用api.我用来获取令牌的代码如下所示:
AuthenticationContext ac = new AuthenticationContext(authority);
AuthenticationResult ar = ac.AcquireToken(resourceID, clientID, redirectURI);
string accessToken = ar.AccessToken;
Run Code Online (Sandbox Code Playgroud)
现在我需要注销并切换到另一个用户,但不知何故系统会记住用户凭据.我在身份验证上下文中清除令牌缓存并发布logout api请求,如下所示,其中***是我的租户ID.
//Log out after api call
ac.TokenCache.Clear();
string requestUrl = "https://login.windows.net/***/oauth2/logout";
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
var response = await client.SendAsync(request);
Run Code Online (Sandbox Code Playgroud)
api调用成功但注销不起作用.如何注销并切换到其他用户?