In a discussion titled ‘How can I check in my website if the user is logged in to my Discourse?’, ygramoel explains they are building a desktop app and website alongside a Discourse forum, and want to display extra content to users who are logged into the forum — without forcing them to log in again. They’ve figured out how to initiate login via SSO but are unsure how to detect if a user is already logged in via the forum. Lilly suggests extracting the user ID from the SSO payload and using a Discourse API call to fetch the username and login status, though the exact API endpoint isn’t documented. ygramoel clarifies they don’t know how to retrieve the SSO payload if the user logs in directly on the forum (not via their app’s SSO link). Lilly speculates that the user_auth_token from the SSO payload might be usable, but admits uncertainty and invites others with SSO expertise to chime in. The core challenge remains: detecting existing Discourse login status on an external site without initiating SSO.
I am building a desktop application, with accompanying forum (running Discourse, of course) and website.
On our website, I would like to show some extra information if the website visitor is also logged in to the forum.
I figured out how to login from the website or desktop application (see this post) , but what I cannot find is a way to check if my website visitor is logged in (and if so, who he is), without actually asking them to login.
Is there a way to do that, e.g. using the Discourse API?
If the user logs in on the forum website, then how can I later get the SSO payload? I know how to get it when I initiate the login myself (by generating a link {forum_url}/session/sso_provider?sso=... etc), but when the user initiates the login, then I have no idea how I could get the SSO payload.
That should indeed be possible, although the exact URL for the API request doesn’t seem to be documented in https://docs.discourse.org. What would be the correct URL?
i’m not sure but i suspect you need to access the user_auth_token from the json data of the payload? just a guess to give you ideas. perhaps someone who knows more about Discourse connect SSO can help you.