The discussion revolves around obtaining a user ID for SSO logout in Discourse. TeoWneD seeks a way to get a user’s ID using their username to log them out via the API. Falco suggests using GET /u/USERNAME.json or GET /u/by-external/EXTERNAL_ID.json to retrieve the user ID. TeoWneD confirms the first method works but struggles with the second. The conversation then shifts to logging out a user, with Falco pointing to a post on Discourse Meta. TeoWneD finds the correct API syntax using admin/users/[UID]/log_out with an API key and username, but encounters issues with redirection after logout. Riking notes the request should be a POST, not a GET, which TeoWneD confirms resolves the issue. However, after logout, a redirect loop occurs. Falco advises setting the logout redirect site setting to a non-authenticated URL, like the homepage or an external site, to prevent the loop.
I searched into many differents posts about SSO logout. But i didn’t found my answer.
We want to setup the SSO LOGOUT.
You also have to know that we implemented SSO.
What is the query, that can return the UID, when i input username.
With that query we will be able to logout a user on the forum that just logout from the main website
This is the closest answer i found.
Can’t we just use sso,sig and token to identify ourself to the forum ? i mean by that that the main website already has those information, is there any way to use it to identify the user we want to logout
Thanks great helping, It’s working for https://example.com/u/USERNAME.json Where i can find myself by replacing example.com (by the forum url) and USERNAME (by my username)
but for https://example.com/u/by-external/EXTERNAL_ID
When i tryed the same logic : Replacing example.com by the forum url and replacing EXTERNAL_ID by : 1,2,3 and some random value.
So yeah it was the right syntax but : https://forum.[website].com/admin/users/[UID]/log_out?api_username=[username]&api_key=[api_key] It’s just leading to an admin page where i can manually disconnect the user.
i also tryed in incognito mode and the querry did’nt went threw it just said that i had been disconnected ( my admin account is’nt connected to the main website because of incognito mode) but as i puted the admin key in the querry it should work right ?
So with a GET querry modified and send again as a POST, to disconnect a user, we have the modale that open to : “say you’ve been disconnected click refresh”
So that is a good sign, but when we click refresh, it just start a infinite loop that lead to a “Bad redirection page”
As you can see on that screenshot:
Question is : What do we have to do to avoid the bad redirection, it looks like it’s because as the user is disconnected from main website and just been disconnected from forum, the forum keep asking to the main website if some one is connected. But when i tryed to fill the logout redirection, It’s changing nothing