Discourse API - where to start? what is my API url?

(riz) #1


I’m really struggling to find any examples or documentation on using the API

All i want to do is create a new user using the API
now i don’t know if this is that same thing as SSO using the API,

Use case:
I have my website (it’s not wordpress or ruby), i have users authenticating to my website.
I want them to automatically have access to my discourse forurm (without having to sign in again).

So how would i do this through implementing API calls?

What is my API url?
How do i find my secret password etc

I seen a image with an API dashboard, how do i even navigate to that?

(Cee Kay) #2


You can read the API documentation here. First go through that please.

(riz) #3

Dear Sir,

This is useful, but i feel there is a step i need to know before this.

Like how do i actually make a simple API call.

As an example, i want to create a user so i look at this api documentation, and it shows the code pasted below.

But what would i type before that code, how would i authenticate to the REST API,
What would be my rest API or jason. i dont even know which it is yet.

So i almost need the basic step before this, and a very simple but complete example, so i can just perform a simple task by typing it into the browser URL, and then from their, i can start to move forward.

Any more suggestions, on how to get the very very basic thing working?

“name”: “string”,
“email”: “string”,
“password”: “string”,
“username”: “string”,
“active”: true,
“approved”: true

(riz) #4

I also found this in terms of generate API key
OK, so i’m guessing i use this somwhere, but where and when?

And what is my api key? is there a dashboard i go to find that out or what?

“api_key”: {
“id”: 0,
“key”: “string”,
“user”: {}

(Cee Kay) #5

Go to yoursitename_com/admin and click API. You can generate the API key from there.

(riz) #6

Dear Sir,

That’s where i thought it would be as well, but when i go to my /admin page, the word API is not on that page anywhere

I just did a Cntrl Find “API” and its not there

I’m using a hosted version of discourse, hosted by discourse.org, so the setup of discourse should all be correct.

So do i need to enable something to see the API link on the admin page?

(riz) #7

So this is exactly where i am navigating to

(riz) #8

Dear Sir,

I’ve made some progress, i found the API section in admin

I was logged in as my moderator, now im in as an admin and can see all the options.

So anyway, when i generate a key, should i be making a master key or a user specific key?

(Robin Ward) #9

If you want to create a user, you probably want to use a master key since that is an admin level thing. Be sure to keep the key secret as if anyone finds it they can perform any operation on your site!

(Cee Kay) #10

You should be making a master Key. But be alarmed! and do not share the key.

(riz) #11

I’m a little uncertain if i should be making a new user or setting up SSO.

So what i want to have happen is that people who sign into my website, they can automatically post to my discourse forum.

So should i be researching how to setup SSO or how to create users?

(Cee Kay) #12

Better learn to set up SSO

(riz) #13


Are you able to give me some high level direction on how to achieve this or point me to some resources?

(Rafael dos Santos Silva) #14

Our official docs have everything you need to implement SSO.

(riz) #15

Dear Sir,

I’ve read that page, and it’s not easy to follow.

So i could go into my admin and enable SSO and do all that,

But then on the other end, i’m unsure exactly what to do, the link you sent talk about it to some extent, but i’m still rather uncertain of how to aheive it.

An actual video walkthrough would be good.

Allot of the example focus on wordpress or ruby. I’m using a custom website that is not on wordpress or on ruby,

(Rafael dos Santos Silva) #16

To implement SSO, you will need to create a web service that will handle receiving a request, and crafting a response.

It will be largely related to the code involved in your own site authentication and authorization.

The same developer who engineered your custom site auth should be able to create this new route. If any specific roadblock is found you can create a topic in #dev about it.

Also, if you found that SSO is too much trouble, enabling the usual social logins (Facebook/Twitter/Google) should suffice.

(riz) #17

I’ve built my site on bubble.is myself, it’s a nice codefree environment.

There i already have FB login option available, and users can login to my site with either email/pwd or FB.

What i would like is to see an end to end example of how others have done this on their custom site.

Based on that example, i would be able to work out what i need to do on my site.

Any videos or step by step walk throughs of this?

(riz) #18

Can you give me some more info on how to exactly create a user?

Also what is the use case for creating a user?

If i create a user, does that mean that when the users signs in from my custom website (reiconnect.co) then he no longer needs to sign into discourse, and can post straight away

(Robin Ward) #19

Sorry I was just trying to help you figure out how to use the API. Using the API to create a user doesn’t mean anyone will be logged in.

What it sounds like you want is to implement SSO. I’d suggest reading this topic. Your custom website can provide the SSO.

Having said that I think they’ll still have to click the Login button on the forum, it’ll just require no additional steps if they’re logged in on your other site. It’ll just redirect them back and they’ll be good to post.

(riz) #20

@eviltrout Thanks,

Yes i need SSO, I’ve read that material, and it seems difficult to setup on my custom site.
It’s lacking an example, like a simple walk through of how one would set that up on their custom website.

Great if someone had like a video walkthrough of how they have set it up.