Synchronizing Changes for SSO users

AI-generated summary

The discussion revolves around synchronizing user changes for SSO (Single Sign-On) users in Discourse. Ply_py explains that while SSO allows overriding user details like email, username, and name, updates aren’t reflected in Discourse until the user logs in, potentially causing missed notifications. They also note that the Discourse API’s PUT method for updating email is restricted, and disabling email overriding triggers a verification email—something they want to avoid since verification is handled externally. Sam suggests using the SSO synchronization endpoint, which Ply_py finds helpful. They also ask about importing SSO users via the POST /users endpoint, noting issues with usernames containing dots and unwanted welcome emails. Sam acknowledges the need for better documentation and samples. AdamCapriola references a prior discussion on the topic, and techAPJ confirms the endpoint exists and has added a sample in the discourse_api repository.

Hi here. We used the SSO feature to connect the Discourse with our own account. As we manage accounts info on our own sites, we enabled email overriding, username overriding and name overriding. However, when a user changed his info, say email, the modification won’t be on effect until the user login Discourse, and he may lose some notification emails during this period.

I’ve tried the Discourse API.Yet, it seems that the PUT method for user’s email is being prohibited. What’s more, if I uncheck the email overriding, the PUT request I send will trigger a verification email. That’s not the way I wanted, as you see we’ve already done the verification on our own SSO site, so it’s totally redundant. But I haven’t found an option to turn off that verification email.

Can someone help me here, thanks.

There is an endpoint for synchronizing sso you should be using that

Thanks, it’s really helpful.

And one more question about account creation. This post How to import SSO users suggests that we can use this endpoint POST /users to import a SSO user. However, sometimes the username we use will contradict with Discourse’s restrictions, specifically our account may have “.” (Dot). Moreover, it will send welcome message as well, what’s the correct way to do this?

We don’t have any sample for this pre-staging, you would need to use the object model direct.

@techAPJ we should have a discourse api sample for this and add missing endpoints.

I posted about this a while ago:

https://meta.discourse.org/t/sso-overrides-email-prevents-api-from-changing-email/15259

An example for utilizing that endpoint would be helpful. :book:

The endpoint was already present, added the sample in discourse_api:

https://github.com/discourse/discourse_api/pull/84