"push" sso-gebruikers naar discourse?

AI-generated summary

In a discussion titled “push sso users to discourse?” under the SSO category, mrkurt asked if it’s possible to programmatically create topics for SSO users without requiring them to go through the login flow. simon responded that while the sync_sso route can create or update users programmatically, it doesn’t log them in. mrkurt noted that this workaround wouldn’t be necessary if new topic parameters persisted through the SSO login flow — currently, users are redirected to a blank topic form if not already logged in. simon suggested the parameters may be stripped by the SSO implementation, not Discourse, and pointed to an example for pre-filling personal messages — which should also work for topics. mrkurt confirmed the approach works, sharing a sample URL that pre-fills a new topic (though it doesn’t redirect correctly), and noted it’s easy to link directly to the SSO URL for a seamless experience.

We want to programmatically create new topics for our users from a backend service. Is it possible to push a SSO user to discourse without them going through the login flow?

If you are using DiscourseConnect to authenticate users on your site, you can create or update users programmatically with this method: Sync DiscourseConnect user data with the sync_sso route. Note that this doesn’t log the user into Discourse, it just creates the user. If that is not what you are trying to accomplish, send us more details about what you are wanting to do.

We are! That’s perfect.

Incidentally, we wouldn’t need to do this if the new topic parameters survived the SSO sign on flow. We can’t find the right incantation to make that work, though, so it dumps people to a blank topic form if they aren’t already logged in. I can file that as a bug somewhere if you consider it a bug. :slight_smile:

It should be possible to get that to work. If the parameters are being stripped, I suspect they are being stripped by the SSO code you are using, not by Discourse. Have a look at this post for details: Creating pre-filled personal message links - #11. Note that the example URL in that post is creating a new PM, not a new topic. The same approach should work for creating a new topic though.

Oh that does work! Nice. This URL doesn’t return to right, but it’s super easy to link to the SSO URL:

http://localhost:3000/new-topic?title=wat&category=questions-and-help/build-debugging&tags=build```