DiscourseConnect调用接口admin/users/sync_sso404错误

科技思考有温度 2024-05-28 02:03:39

在对用户数据通过 SSO 同步的时候,调用提示 404 错误。

我们使用的是 Java 的代码。

如上图,返回显示的代码为 404。

问题原因

出现上面错误的原因是安装的 Discourse 实例的 discourse connect 没有启用。

当这个选项不启用的话,API 调用的同步就会显示 404 没有找到。

启用后的就会显示其他的信息。

下图是当上面的接口调用成功后显示的 200 代码。

API 也会返回一个完整的用户相关数据。

数据结构是 JSON 的。

其实内容还蛮多的,你可以用这个把数据同步回 SSO 单点登录服务器上。

{ "id": 17, "username": "info.visafn.sso", "name": "Info Visafn Sso", "avatar_template": "/letter_avatar_proxy/v4/letter/i/7ba0ec/{size}.png", "active": true, "admin": false, "moderator": false, "last_seen_at": "2024-05-22T20:14:45.926Z", "last_emailed_at": "2024-05-22T20:32:54.369Z", "created_at": "2024-05-21T18:53:53.081Z", "last_seen_age": 87821.707032433, "last_emailed_age": 86733.264398046, "created_at_age": 179074.552034788, "trust_level": 1, "manual_locked_trust_level": null, "title": null, "time_read": 0, "staged": false, "days_visited": 1, "posts_read_count": 0, "topics_entered": 0, "post_count": 0, "can_send_activation_email": true, "can_activate": false, "can_deactivate": true, "ip_address": null, "registration_ip_address": null, "can_grant_admin": true, "can_revoke_admin": false, "can_grant_moderation": true, "can_revoke_moderation": false, "can_impersonate": true, "like_count": 0, "like_given_count": 0, "topic_count": 0, "post_edits_count": null, "flags_given_count": 0, "flags_received_count": 0, "private_topics_count": 1, "can_delete_all_posts": true, "can_be_deleted": true, "can_be_anonymized": true, "can_be_merged": true, "full_suspend_reason": null, "silence_reason": null, "penalty_counts": { "silenced": 0, "suspended": 0 }, "next_penalty": "2024-05-24T20:38:27.655Z", "primary_group_id": null, "badge_count": 1, "warnings_received_count": 0, "bounce_score": 0, "reset_bounce_score_after": null, "can_view_action_logs": true, "can_disable_second_factor": true, "can_delete_sso_record": true, "api_key_count": 0, "external_ids": {}, "single_sign_on_record": { "user_id": 17, "external_id": "1", "created_at": "2024-05-21T18:53:53.280Z", "updated_at": "2024-05-21T18:56:21.866Z", "external_username": "info.visafn.sso", "external_name": null, "external_avatar_url": null, "external_profile_background_url": null, "external_card_background_url": null }, "approved_by": null, "suspended_by": null, "silenced_by": null, "groups": [ { "id": 10, "automatic": true, "name": "trust_level_0", "display_name": "trust_level_0", "user_count": 14, "mentionable_level": 0, "messageable_level": 0, "visibility_level": 1, "primary_group": false, "title": null, "grant_trust_level": null, "incoming_email": null, "has_messages": false, "flair_url": null, "flair_bg_color": null, "flair_color": null, "bio_raw": null, "bio_cooked": null, "bio_excerpt": null, "public_admission": false, "public_exit": false, "allow_membership_requests": false, "full_name": null, "default_notification_level": 3, "membership_request_template": null, "members_visibility_level": 0, "can_see_members": true, "can_admin_group": true, "publish_read_state": false }, { "id": 11, "automatic": true, "name": "trust_level_1", "display_name": "trust_level_1", "user_count": 14, "mentionable_level": 0, "messageable_level": 0, "visibility_level": 1, "primary_group": false, "title": null, "grant_trust_level": null, "incoming_email": null, "has_messages": false, "flair_url": null, "flair_bg_color": null, "flair_color": null, "bio_raw": null, "bio_cooked": null, "bio_excerpt": null, "public_admission": false, "public_exit": false, "allow_membership_requests": false, "full_name": null, "default_notification_level": 3, "membership_request_template": null, "members_visibility_level": 0, "can_see_members": true, "can_admin_group": true, "publish_read_state": false } ]}
0 阅读:0

科技思考有温度

简介:感谢大家的关注