How to logout user by api

For while I am trying to logout user by api, but without success,

I did read SSO Logout via Master API Key isn't working - #2 by simon

My httpclient has set username and api key inside headers, and it works for other stuff e.g. post get user by external id or other.

Do I need to send api-key and api-username in body also.

My users are logged in by sso, when I logout user from admin page on discource it works.

Here is part of code how do I trying to call it

var formData = new FormUrlEncodedContent(new
{
new KeyValuePair<string, string>(“username_or_email”, user.user.username)
});
var response = await _httpClient.PostAsync($“/admin/users/{user.user.id}/log_out”, formData);
var content = await response.Content.ReadAsStringAsync();

Response returns 200 code but content are web page not {Succes: “OK” }

My apologies for opening topic.

Problem was that my development setup point to http not https instance of discource.

When I switched to https endpoint it start working.

I get confused because some of api endpoints woking over http but this on does not.

For future readers here how i logout users by C#

             var url = $"/admin/users/{user.user.id}/log_out";
            using var formData = new MultipartFormDataContent{
{ new StringContent(_forumConfigModel.ApiKey), “api_key” },
{ new StringContent(_forumConfigModel.User), “api_username” }
};

var response = await _httpClient.PostAsync(url, formData);
1 Like