Create SSO Users, Adding To Group, Subscribing to Category via API


#1

Hi,

Our external system needs to integrate with Discourse. Discourse is currently using SSO to authenticate against our external system with no issues. However, we need to automate a few things:

  1. External users need to be added in advanced of logging into Discourse.
  2. After being added, external users need to be added to a specific Security Group.
  3. External users need to be subscribed to receive updates from a specific Category.

Overall, the goal is as new users join the external system (an ASP.net MVC app) they also join Discourse and receive updates from a specific category.

Can all of this be done just using the API?

It’s my understanding that one can use the API to create a user as “Staged” via the API. However, I’m not sure this can be done on SSO users of if the users can receive email updates from subscribed categories.

I’m not sure if a user can be subscribed to receive updates from a specific category using the API or not.

Thank you.


API call to have a user watch specific category(ies)?
(Rafael dos Santos Silva) #2

This is all possible and I did exactly this years ago.

First, since you want users to receive updates before “creating the account” go with normal users and not staged.

When a user create a new account on your current app, you will

  1. Send API request to create a new user

  2. Send API requests to add it to groups

  3. Send API request to make it watch some categories


API call to have a user watch specific category(ies)?
#3

Thanks @Falco. I mentioned creating staged users because of what I read in this thread. Perhaps I misunderstand what the aforementioned thread was saying.

Did you also make calls with .Net? If so, do you know of any .Net API wrappers or know where I might find an example of calling the API with .Net to create a user using the API key?

Thanks again.


(Dimitris Kritsotakis) #4

Hello, in ESN Greece (there is a cas server), so after the authentication, the user info is available in our PHP app, which next it will redirect back to discourse. (SSOhelper)

fields you may send back to discourse are

   'username' => string,
    'name'     => string,
    'avatar_url' =>  string->url,
    'add_groups' => discourse group names seperated with comma,
    'remove_groups' => discourse group names seperated with comma

About some categories based on Group you may edit your Groups @ discourse level and set them what categories to watch by default


#5

@Falco perhaps I’m just missing it, but I cannot find the API call to make a user watch a category(ies). Do you know which API call you used to do this?


#6

@Webmaster_ESN_Greece perhaps I’m not understanding correctly, but the there doesn’t appear to be a way in the Discourse UI to set categories to watch by default when editing a group. Would you ming be more specific?

Thank you.