有人知道如何从 API 获取用户的“external_id”吗?我在 SSO 登录时添加了 external_id,但现在查询用户时,在 API 返回的用户哈希中看不到任何“external_id”。我试图使用 external_id 作为在 webhook 处理过程中从我的数据库中识别用户的方式。
是的,可以通过向 https://discourse.example.com/u/by-external/{external_id}.json 发送经过身份验证的 GET 请求来实现。
该路由的文档见:Discourse API Docs
2 个赞
要获取反向映射(即根据 user_id 获取 external_id),您可以选择以下任一方法:
-
使用 Discourse Ruby API 并调用方法:user_sso(user_id)
-
向以下地址发送 已认证的 GET 请求:
https://discourse.example.com/admin/users/{id}.json
并查找哈希键 [“single_sign_on_record”][“external_id”]
请注意,调用以下地址不会返回 single_sign_on_record(以及 external_id):
https://discourse.example.com/users/{username}.json
2 个赞
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.