# How to get a feed from a password protected Discourse?

**URL:** https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602
**Category:** Development
**Tags:** rest-api
**Created:** [6월 3, 2015, 1:48오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602 "2015-06-03T13:48:31Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![strategeek](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@strategeek](https://meta.discourse.org/u/strategeek)
#### Post date: [6월 3, 2015, 1:48오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/1 "2015-06-03T13:48:31Z")

</div>

Hello. I need to display password protected Discourse feed on the external site. How to do that?

Other sites suggest using this structure http://[username]:[password]@[domain]/[path]  
But for Discourse it doesn’t work.

By the way, the external site that I want to show the feed is a wordpress page. Discourse is linked to this page with SSO.

Any ideas?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [6월 3, 2015, 3:07오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/2 "2015-06-03T15:07:12Z")

</div>

I assume you mean RSS feeds.

You can generate an API key for a user account on your site in the admin section. Then you can just append it to any URL like so:

`http://meta.discourse.org/latest.rss?api_key=KEYHERE`

I should note there are security issues with making that api key visible to users. If someone has it, they can do anything that the underlying user account can do. It would be much better to fetch the RSS server side using the key then only exposing the resulting feed.

Also, be especially careful not to generate an “All Users” key for this. If someone gets that key they can do anything as _any_ user on your site. So just be extra careful 😄

---

<div class="post-metadata">

### Author: ![strategeek](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@strategeek](https://meta.discourse.org/u/strategeek)
#### Post date: [6월 4, 2015, 6:45오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/3 "2015-06-04T06:45:50Z")

</div>

Great answer, eviltrout. Thank you very much 😄

---

<div class="post-metadata">

### Author: ![dansingerman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dansingerman/32/115687_2.png) [@dansingerman](https://meta.discourse.org/u/dansingerman)
#### Post date: [9월 4, 2015, 8:49오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/4 "2015-09-04T08:49:36Z")

</div>

We are having the issue that the RSS feeds do not work with an api\_key if the categories have read restrictions, even if the api\_key is valid for a user that should be able to access the category.

Is this a bug or by design?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [9월 4, 2015, 5:17오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/5 "2015-09-04T17:17:47Z")

</div>

> [@dansingerman](#):
>
> Is this a bug or by design?

That sounds like a bug to me. The API key should function as the user associated with it. Are you passing the correct username through too?

---

<div class="post-metadata">

### Author: ![dansingerman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dansingerman/32/115687_2.png) [@dansingerman](https://meta.discourse.org/u/dansingerman)
#### Post date: [9월 8, 2015, 3:26오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/6 "2015-09-08T15:26:15Z")

</div>

No, I’m not passing a username, as I am using a key associated with a user.

If I try in an unauthenticated session:

[http://myserver.example.com/latest.json?api\_key=my\_api\_key](http://myserver.example.com/latest.json?api_key=my_api_key)

I get the results I expect

If I try

[http://myserver.example.com/latest.rss?api\_key=my\_api\_key](http://myserver.example.com/latest.rss?api_key=my_api_key)

I get no results.

So unless RSS has some special case of how to use API keys, I think it may be a bug

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [10월 18, 2017, 9:06오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/7 "2017-10-18T09:06:09Z")

</div>

This was a bug, now fixed via:

[https://github.com/discourse/discourse/commit/f50d4478810a0d5616ba06448dcae51aaeccb192](https://github.com/discourse/discourse/commit/f50d4478810a0d5616ba06448dcae51aaeccb192)

---

<div class="post-metadata">

### Author: ![scombs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/scombs/32/48616_2.png) [@scombs](https://meta.discourse.org/u/scombs)
#### Post date: [11월 12, 2017, 12:42오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/8 "2017-11-12T00:42:12Z")

</div>

With the new fix, I am able to view restricted **categories** in the RSS feed at …

[http://myserver.example.com/c/my\_category.rss?api\_key=my\_api\_key](http://myserver.example.com/c/my_category.rss?api_key=my_api_key)

but **Latest** only shows public topics in the RSS feed

[http://myserver.example.com/latest.rss?api\_key=my\_api\_key](http://myserver.example.com/latest.rss?api_key=my_api_key)

Is this still unresolved or am I missing something? Thanks.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1월 1, 2020, 11:36오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/9 "2020-01-01T23:36:33Z")

</div>



---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [1월 2, 2020, 1:48오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/10 "2020-01-02T01:48:30Z")

</div>

API 키는 이제 헤더에 포함해야 하지 않나요 @sam?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [1월 2, 2020, 1:50오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/11 "2020-01-02T01:50:00Z")

</div>

네, 지원하긴 합니다! @blake 현재 환경에서 사람들이 개인용 RSS 피드를 어떻게 사용할지에 대해 의견이 있으신가요? 브라우저나 RSS 리더가 인증을 위한 커스텀 헤더를 지원하나요?

상당히 드문 사용 사례이지만, 우회 방법이 있으면 좋겠습니다.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [1월 2, 2020, 4:55오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/12 "2020-01-02T04:55:22Z")

</div>

RSS와 인증에 관련된 유일한 사항은 `https://user:password@www.example.com`과 같은 URL 기반의 기본 인증(Basic Auth)에 대한 지원(현재 지원하지 않음)이거나, 현재 URL에서 api\_key와 api\_username으로 지원하는 것과 유사한 방식입니다.

URL 기반 인증을 완전히 폐기하는 것이 좋았겠지만, 비공개 RSS를 계속 지원하기 위한 앞으로의 방향은 이러한 유형의 인증을 주제/카테고리 피드에만 허용하는 것입니다. 이후에는 읽기 전용 API 키에 대한 지원도 추가할 수 있습니다.

문제는 RSS 리더가 피드를 추가할 때 URL 입력란 하나만 제공한다는 점입니다. 따라서 RSS가 헤더를 지원하더라도, 리더에 헤더에 자격 증명을 추가할 곳이 없습니다.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [1월 2, 2020, 7:56오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/13 "2020-01-02T07:56:51Z")

</div>

> [@blake](#):
>
> URL 기반 인증을 완전히 폐기하는 것이 이상적이었을 것 같지만, 비공개 RSS를 계속 지원하기 위한 전진 방향은 이 유형의 인증을 주제/카테고리 피드에만 허용하는 것이라고 생각합니다. 그리고 나중에 읽기 전용 API 키 지원도 추가할 수 있을 것입니다.

@david의 스코핑 작업과 관련되어 여기에서 떠오르는 아이디어 중 하나는, 단일 RSS 피드에 엄격하게 스코프가 지정된 사용자 API 키를 만들 수 있다는 것입니다. 이렇게 하면 공격 표면이 작아지고, 이러한 경우처럼 초소형 스코프의 사용자 API 키를 사용하는 경우에는 헤더 없이도 허용할 수 있습니다(사용자 API 키에 해당 키가 GET 인증에 사용될 수 있음을 나타내는 컬럼을 추가하는 방식).

여기서 도전 과제는 다음과 같습니다:

1. 사용자가 사용자 API 키를 생성할 수 있는 메커니즘이 없습니다. RSS 사용 사례를 위해 무언가를 구축해야 하며, 이는 새로운 UX를 포함하게 됩니다. 어디에 추가해야 할지 확실하지 않습니다. 아마도 사용자 프로필에 추가할 수 있겠지만, 모르겠습니다.

2. 특정 RSS 피드 하나에만 스코프를 좁힐 수 있는 메커니즘이 없으며, 이를 추가해야 합니다.

3. URL GET 매개변수를 통해 "허용된 사용자 API 키"를 식별할 수 있는 플래그가 없으며, 이를 위해 필요합니다.

전체적으로 이 문제는 해결할 수 있다고 보지만, 정확히 작동하도록 만드는 데는 아마도 1~2주 정도의 작업량이 필요할 것입니다.

장점은 이 작업 중 일부는 RSS와 무관하게 우리가 하고 싶은 작업이라는 점이지만, 단점은 일부 작업이 RSS와 매우 강하게 결합되어 있고, 요즘 이 기능을 사용하는 사람이 매우 적다는 점입니다.

어떻게 우선순위를 정할지는 @codinghorror의 판단에 맡기는 것 같습니다.

---

<div class="post-metadata">

### Author: ![xadium](https://avatars.discourse-cdn.com/v4/letter/x/ac91a4/32.png) [@xadium](https://meta.discourse.org/u/xadium)
#### Post date: [1월 6, 2020, 2:20오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/14 "2020-01-06T14:20:22Z")

</div>

> [@sam](#):
>
> 장점은 이 작업 중 일부는 RSS와 무관하게 우리가 하고 싶어 하는 작업이라는 점이고, 단점은 일부 작업이 RSS와 매우 긴밀하게 결합되어 있다는 점입니다. 요즘 이 기능을 사용하는 사람이 매우 적거든요.

저는 WordPress와 Discourse를 SSO를 통해 연동하고 있습니다. API를 사용해 여러 카테고리의 RSS 피드를 활용하여 WordPress에서 최근 게시물 사이드바를 생성하고 있기에, 이를 위해 URL 인증 메커니즘을 유지하고 싶습니다. 그렇지 않으면 헤더 인증 옵션을 구현하기 위해 커스텀 위젯을 직접 작성해야 하는 번거로움을 감수해야 합니다. 따라서 이 기능을 사용하는 소수의 사용자 중 한 명으로서 +1을 표합니다.

---

<div class="post-metadata">

### Author: ![Jack\_Ukleja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jack_ukleja/32/197752_2.png) [@Jack\_Ukleja](https://meta.discourse.org/u/Jack_Ukleja)
#### Post date: [3월 20, 2021, 9:44오후 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/15 "2021-03-20T21:44:43Z")

</div>

> [@blake](#):
>
> 사적인 RSS 피드를 지원하기 위해 앞으로 나아갈 길은 이 유형의 인증을 주제/카테고리 피드에만 허용하고, 나중에 읽기 전용 API 키 지원도 추가하는 것이라고 생각합니다.

현재 이것이 지원되는지 아닌지 알려줄 수 있는 사람이 있을까요?

동작하도록 만드는 데 어려움을 겪고 있습니다.

쿼리 문자열에 API\_KEY를 사용하려고 하면 다음과 같은 오류가 발생합니다:

> 요청한 리소스를 볼 권한이 없습니다. API 사용자 이름 또는 키가 유효하지 않습니다.

이는 적어도 쿼리 문자열을 읽으려고 시도하고 있음을 시사합니다.

**업데이트:**

이제 어찌어찌 작동하는 것 같습니다. RSS 피드의 일부만 사용 가능한 것 같고, 모두는 아닌 것 같습니다. API 키 설정을 살펴보면 다음을 액세스할 수 있는 것 같습니다:

**읽기(read)**

- `/t/:slug/:topic_id.rss`

**목록 읽기(read lists)**

- `/c/*category_slug_path_with_id.rss`
- `/top/all.rss`
- `/top/yearly.rss`
- `/top/quarterly.rss`
- `/top/monthly.rss`
- `/top/weekly.rss`
- `/top/daily.rss`

이것이 기본적인 `/latest.rss`와 `/top.rss`를 _제외하는_ 이유가 무엇인지 아는 사람이 있을까요?

---

<div class="post-metadata">

### Author: ![sptrf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sptrf/32/232521_2.png) [@sptrf](https://meta.discourse.org/u/sptrf)
#### Post date: [9월 3, 2021, 4:08오전 UTC](https://meta.discourse.org/t/how-to-get-a-feed-from-a-password-protected-discourse/29602/16 "2021-09-03T04:08:35Z")

</div>

API 키를 사용하여 RSS를 가져올 때, 올바른 데이터를 가져오려면 accept 헤더를 지정해야 하는 것 같습니다.

- `curl https://bbs.example.com/c/cat.rss?api_key=KEY`처럼 accept 헤더를 지정하지 않고 RSS를 가져오면 `< HTTP/1.1 404 Not Found` 페이지가 반환될 수 있습니다.
- 그러나 accept 헤더를 지정하면 RSS XML을 올바르게 가져올 수 있습니다. 예를 들어:

```plaintext
curl 'https://bbs.example.com/c/cat.rss?api_key=KEY' \
  -H 'application/xhtml+xml' \

```
