Access topics in locked categories through API

(steven_yue) #1


I’m trying to use our API to access the latest topic in a category. I’m using the ruby gem.

The API key is created under an admin user. And the category I’m trying to access is a locked one, which is not shown to public, and only admin can edit and view it.

I’m using client.category_latest_topics(slug) to access the topics, but always get error like below:

`handle_error': [error: 'invalid access'] (DiscourseApi::UnauthenticatedError)

So seems like even though the user has the access right, it will still block user through API access?

I’m using Discourse v1.2.1

(Kane York) #2

Are you making sure to pass api_key AND api_username in the GET or POST parameters?

(steven_yue) #3

Yes, I’m using the discourse_api gem. I tried on public category and it’s working.

(Kane York) #4

What’s the actual request being sent?

(steven_yue) #5

The code is similar like this:

client ="")
client.api_key = "key_str"
client.api_username = "admin_username"