# 通过 Discourse API 访问，key 或 user 被拒绝

**URL:** https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947
**Category:** Development
**Tags:** rest-api
**Created:** [2023年十一月29日 09:47 UTC](https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947 "2023-11-29T09:47:07Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十一月29日 16:28 UTC](https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947/2 "2023-11-29T16:28:27Z")

</div>

DiscourseClient Python 库旨在与 _管理员_ API 密钥（管理员 → API）配合使用。  
您从 `generate_api_key` 生成的是 [_客户端_ API 密钥](https://meta.discourse.org/t/user-api-keys-specification/48536)。  
您需要改用 `API-User-Key` 和 `API-User-Username` 标头。  
例如：

```plaintext
curl https://forum.example.com/t/95783.json -H 'Api-User-Key: 388b79103056fede1d3223dae032df99' -H 'Api-User-Username: tflidd'

```

---

_[View the full topic](https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947)._
