The discussion explores how an API user can create posts on behalf of other authenticated users in Discourse. Initially, users inquire about leveraging existing JWT tokens or using a master API key to impersonate users. It’s clarified that specifying the api_username parameter in the query string was a previous method, but this has changed. The current approach involves using the Api-Username HTTP header when making API requests, provided the API key has permissions for all users blake. This method allows creating posts as any user without needing individual API keys per user. Some users also consider migration scripts as an alternative for bulk content import, but the focus remains on API-based solutions dariKG.
I’m using the API of Discourse with a custom UI. I’m attempting to integrate this behind an orchestration layer that already authenticates users. I’d like to be able to more or less bypass authentication on the Discourse side of things.
We use JWT tokens, and it seems that ideally I could just pass these along to Discourse and tell it to trust them. I see that there’s some JWT related projects in the discourse GitHub organization, but there’s no documentation or usage examples, Google hasn’t been helpful, I haven’t found any relevant threads in meta, and I don’t really speak Ruby
Is there a way I could leverage our existing authentication by just passing these tokens through to Discourse?
Failing that, as an API user, how can I create topics and posts on behalf of other, authenticated users?
I’m trying to do this, but I cannot specify an arbitrary username as api_username - if I specify any username other than my (admin) account, I get a 404 from the API.
Is this post out of date, or is there some other way to achieve creating topics as another user (other than creating an API key for every user)?
Пишу, потому что пытаюсь наполнить свой форум постами от группы пользователей с другого старого форума.
В документации объясняется, как создать пост через API, но я не уверен, как сделать так, чтобы эти посты отображались как написанные конкретным пользователем. Предложенное выше решение, похоже, больше не работает.
Есть ли поле, куда можно ввести имя пользователя? Я не могу найти его в документации.
Вы думали о том, чтобы попробовать скрипт миграции?
Это может быть гораздо проще. И здесь, на Meta, есть множество пошаговых руководств в зависимости от того, на какой платформе работал ваш старый форум.