# 是否有一个后端API可以自动管理所有用户及其权限？

**URL:** <https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069>\
**Category:** Support\
**Created:** [2024年十二月31日 20:24 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069 "2024-12-31T20:24:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Traflagar](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Traflagar](https://meta.discourse.org/u/Traflagar)\
**Post date:** [2024年十二月31日 20:24 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/1 "2024-12-31T20:24:05Z")

</div>

例如，我有一个 Supabase-Stripe 集成，用于管理我网站上的用户帐户。不同级别的订阅者可以访问或无法访问某些论坛类别。

是否有方便的 API 来处理我网站订阅者的 Discourse 帐户创建和权限？或者其他解决方案？

即使是自动向用户发送邀请电子邮件的方式也会有所帮助。我不知道如何正确检查 Discourse 是否有用于这些目的的 API，只能问一下！

---

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2024年十二月31日 20:28 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/2 "2024-12-31T20:28:35Z")

</div>

你读过这个话题了吗？

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. Many of the endpoints are properly documented in the [discourse\_api](https://github.com/discourse/discourse_api) gem, however some endpoints lack documentation. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select XHR filter: Perform the op…

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2024年十二月31日 21:24 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/3 "2024-12-31T21:24:33Z")

</div>

不过，我认为没有办法导入用户订阅，只能导入产品，因此新用户将自动添加到正确的组中。

您需要想办法导入用户。如果用户数量超过一百个左右，导入脚本会比 API 更容易。

---

<div class="post-metadata">

**Author:** ![Traflagar](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Traflagar](https://meta.discourse.org/u/Traflagar)\
**Post date:** [2024年十二月31日 22:07 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/4 "2024-12-31T22:07:03Z")

</div>

我会看看我能走多远。

---

<div class="post-metadata">

**Author:** ![MihirR](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mihirr/32/475158_2.png) [@MihirR](https://meta.discourse.org/u/MihirR)\
**Post date:** [2025年一月1日 14:00 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/5 "2025-01-01T14:00:25Z")

</div>

> [@Traflagar](#):
>
> 是否有方便的 API 来处理我的网站订阅者的 discourse 账户创建？

要创建账户，端点是：`url = f"{DISCOURSE_URL}/users.json"`，您通常可以通过连接并使用管理员 API 轻松创建账户。

此外，此端点可以帮助您处理几乎所有的基本权限，对于自定义权限，没有这样的特定端点，但您可以轻松地在网络选项卡中进行检查和查找，这样就可以完成工作。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2025年一月2日 15:10 UTC](https://meta.discourse.org/t/is-there-a-back-end-api-where-i-can-manage-all-of-the-users-and-their-permissions-automatically/345069/6 "2025-01-02T15:10:06Z")

</div>

您可能需要使用 discourse\_connect，以便您的网站可以管理 Discourse 登录。如果您的网站是 WordPress，那么这很简单（只需使用 wp-discourse）；如果不是，那么您需要实现 discourse\_connect。
