# Access via Discourse API, key and/or user rejected

**URL:** <https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [November 29, 2023, 9:47am 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:** 3

<div class="post-metadata">

**Author:** ![tflidd](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tflidd](https://meta.discourse.org/u/tflidd)\
**Post date:** [December 1, 2023, 9:26am UTC](https://meta.discourse.org/t/access-via-discourse-api-key-and-or-user-rejected/286947/3 "2023-12-01T09:26:57Z")

</div>

👍 this works, you don’t know how much time I spent on this.

But the API endpoints are the same described here

> **[Discourse API Docs](https://docs.discourse.org/)**

?

(if yes, it would be great to mention not only how to authenticate with the admin API key but also mention the client API key)

For the pydiscourse client, there is a hacky workaround to use a different header:

```plaintext
from pydiscourse import DiscourseClient

client = DiscourseClient(
        'https://forum.example.com',
        api_username='tflidd',
        api_key='388b79103056fede1d3223dae032df99')

headers = {
            "Accept": "application/json; charset=utf-8",
            "User-Api-Key": '388b79103056fede1d3223dae032df99',
            "User-Api-Username": 'tflidd',
        }

slug = "abc"
topic_id = 1234

client.topic(slug=slug, topic_id=topic_id, override_request_kwargs=override_request_kwargs)

```

---

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