Account Injection for Talk (Discourse)

Hi there. I’m trying to implement the auto account injection for the TALK. One feature that @michael mentioned that would sync all the OpenMRS ID to TALK.

My plan is:

  • Store existing accounts that not stored yet in TALK.
  • Make sure future accounts will be stored in TALK when they finished their registrations, and sync all the modification synchronously.

As this is somehow an important feature that should be deployed ASAP. I need to know the current version of Dashboard in production, i.e. the commit hash code.

And for the sake of error-free, I’m wondering is all the accounts’ username in TALK are the same as their OpenMRS ID. It will be easier for me to check the existence of a​ user.

So the best documentation that I know of is at:

Based on this documentation, the idea is that a POST to Discourse end point /admin/users/sync_sso can be used to update details of the user when details are changed in Dashboard. The data sent should be basically the same that is sent for the log in process.

Also there is an endpoint that provides details on the status of the user such as: This uses the external_id that we send it (the OpenMRS ID). There are some cases where the user name in Discourse is not the same because there can’t be . in the user ID in Discourse. But the official OpenMRS ID is still maintained in this external_id.

Take a look and in case of further questions, let’s just keep this topic going. :slight_smile:

Oops… Yep I’ve checked this documentation. However carelessly, I haven’t noticed the synchronization part. Thanks. :laughing: Things will be much easier then.

BTW, it seems that you’ve found my topic on and liked it :flushed:

1 Like

Yep, unfortunately the Discourse API’s are not yet very well documented (kind of like OpenMRS!) so it takes a lot of research to find what really needs to happen. But we’ll also see what answers come to your meta question. :+1:

@michael @r0bby
I’ve made a PR here for this issue. It will sync the changes with TALK.

At last I’ve chosen to imitate the normal login procedure. Go to the login URL and fetch the nonce (temporary credence for SSO login) and make a request to issue that login. As Discourse will sync the data during login, this will work magically.

And for efficiency, all the HTTP requests are just HEAD requests.

And the script for import will come soon. :smile:


I will review and test this shortly.


@michael I’ve also written a simple script to sync current accounts. The script along with its walkthrough is put here, have a look!

If you have any doubts, please let me know.


I just noticed when testing that users are synced when they login for the first time…

That said, I merged the PR #5 in 71eb128c and closed the ticket.

This can be put into use on the production server with no issues by simply updating the checked out branch and restarting node.

Log in to what? :smile:

If I login to Discourse via ID Dashboard, it creates the account on the first login…I still support the PR being merged and in fact have merged it.

1 Like

This has been the behavior all along. We want the Discourse account created before the user first signs in to Discourse – instead, when their account is created or updated on Dashboard.

That is the behavior currently implemented – and merged :slight_smile:

It can be safely put into use in production if you want – it’s not blocked by the id dashboard master state – since it’s implemented as a module :slight_smile:

Hey, @michael have you tried that script? I’d like to know how it goes.

1 Like