# Get external\_id used in SSO through the API

**URL:** https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611
**Category:** Support
**Created:** [5월 28, 2018, 7:08오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611 "2018-05-28T19:08:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![henriqueberlesi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/henriqueberlesi/32/119922_2.png) [@henriqueberlesi](https://meta.discourse.org/u/henriqueberlesi)
#### Post date: [5월 28, 2018, 7:08오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/1 "2018-05-28T19:08:03Z")

</div>

We are trying to match the sign ups in our forum with our app sign ups.

In my opinion, it seems easier to populate a database when the SSO happens, but this wasn’t implemented yet.

So, is it possible to get the user’s external\_id used in SSO through the Discourse API?

Here is a standard Json for a random user:

```plaintext
"user": {
    "moderator": false,
    "can_change_bio": false,
    "primary_group_flair_bg_color": null,
    "uploaded_avatar_id": null, 
    "title": null,
    "watched_category_ids": [],
    "trust_level": 0,
    "id": 1234,
    "custom_avatar_template": null,
    "muted_category_ids": [],
    "watching_first_post_tags": [],
    "featured_user_badge_ids": [],
    "tracked_category_ids": [],
    "watched_tags": [],
    "mailing_list_posts_per_day": 1,
    "locale": null,
    "watched_first_post_category_ids": [],
    "recent_time_read": 0,
    "primary_group_flair_url": null,
    "user_option": {
        "user_id": 1234,
        "email_digests": true,
        "external_links_in_new_tab": false,
        "like_notification_frequency": 1,
        "enable_quoting": true,
        "mailing_list_mode": false,
        "mailing_list_mode_frequency": 1,
        "email_direct": true,
        "theme_key_seq": 0,
        "theme_key": theme_key,
        "new_topic_duration_minutes": 2880,
        "disable_jump_reply": false,
        "include_tl0_in_digests": false,
        "dynamic_favicon": false,
        "email_always": false,
        "automatically_unpin_topics": true,
        "email_in_reply_to": true,
        "homepage_id": null,
        "allow_private_messages": true,
        "email_private_messages": true,
        "digest_after_minutes": 10080,
        "email_previous_replies": 2,
        "auto_track_topics_after_msecs": 240000,
        "notification_level_when_replying": 2
    },
    "groups": [
        {
            "name": group_name,
            "display_name": display_name
            "automatic_membership_retroactive": false,
            "has_messages": false,
            "bio_raw": null,
            "messageable_level": 0,
            "flair_bg_color": null,
            "incoming_email": null,
            "visibility_level": 0,
            "flair_url": null,
            "id": 1,
            "automatic": true,
            "full_name": null,
            "mentionable_level": 0,
            "public_exit": false,
            "primary_group": false,
            "flair_color": null,
            "grant_trust_level": null,
            "bio_cooked": null,
            "automatic_membership_email_domains": null,
            "membership_request_template": null,
            "public_admission": false,
            "allow_membership_requests": false,
            "title": null,
            "user_count": 1234,
            "default_notification_level": 3
        }
    ],
    "badge_count": 0,
    "can_edit_username": true,
    "can_edit_name": true,
    "gravatar_avatar_template": null,
    "admin": false,
    "last_posted_at": null,
    "can_send_private_messages": true,
    "can_edit_email": true,
    "user_api_keys": null,
    "name": name,
    "profile_view_count": 0,
    "time_read": 0,
    "custom_fields": {},
    "staged": false,
    "created_at": created_at,
    "second_factor_enabled": false,
    "primary_group_flair_color": null,
    "invited_by": null,
    "can_be_deleted": true,
    "primary_group_name": null,
    "system_avatar_upload_id": null,
    "last_seen_at": null,
    "username": username,
    "custom_avatar_upload_id": null,
    "post_count": 0,
    "user_fields": {
        "1": null
    },
    "can_delete_all_posts": true,
    "can_edit": true,
    "has_title_badges": false,
    "card_badge": null,
    "muted_usernames": [],
    "muted_tags": [],
    "system_avatar_template": "",
    "group_users": [
        {
            "user_id": 1234,
            "notification_level": 3,
            "group_id": 1
        }
    ],
    "tracked_tags": [],
    "gravatar_avatar_upload_id": null,
    "avatar_template": "",
    "can_send_private_message_to_user": true,
    "pending_count": 0
}
```

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [5월 28, 2018, 7:24오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/2 "2018-05-28T19:24:40Z")

</div>

The `/admin/users/{user_id}.json` route returns the `single_sign_on_record`.

---

<div class="post-metadata">

### Author: ![henriqueberlesi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/henriqueberlesi/32/119922_2.png) [@henriqueberlesi](https://meta.discourse.org/u/henriqueberlesi)
#### Post date: [5월 28, 2018, 7:35오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/3 "2018-05-28T19:35:51Z")

</div>

That’s exactly the endpoint I’m sending the request but I can’t find the field `single_sign_on_record`.

Also I believe that this is not documented in the API reference right? But I’m getting other fields like `user_options` that doesn’t show in the reference either.

If it helps, this is a standard Json from a random user:

`````plaintext
"user_badges": [],
"user": {
    "moderator": false,
    "can_change_bio": false,
    "primary_group_flair_bg_color": null,
    "uploaded_avatar_id": null, 
    "title": null,
    "watched_category_ids": [],
    "trust_level": 0,
    "id": 1234,
    "custom_avatar_template": null,
    "muted_category_ids": [],
    "watching_first_post_tags": [],
    "featured_user_badge_ids": [],
    "tracked_category_ids": [],
    "watched_tags": [],
    "mailing_list_posts_per_day": 1,
    "locale": null,
    "watched_first_post_category_ids": [],
    "recent_time_read": 0,
    "primary_group_flair_url": null,
    "user_option": {
        "user_id": 1234,
        "email_digests": true,
        "external_links_in_new_tab": false,
        "like_notification_frequency": 1,
        "enable_quoting": true,
        "mailing_list_mode": false,
        "mailing_list_mode_frequency": 1,
        "email_direct": true,
        "theme_key_seq": 0,
        "theme_key": theme_key,
        "new_topic_duration_minutes": 2880,
        "disable_jump_reply": false,
        "include_tl0_in_digests": false,
        "dynamic_favicon": false,
        "email_always": false,
        "automatically_unpin_topics": true,
        "email_in_reply_to": true,
        "homepage_id": null,
        "allow_private_messages": true,
        "email_private_messages": true,
        "digest_after_minutes": 10080,
        "email_previous_replies": 2,
        "auto_track_topics_after_msecs": 240000,
        "notification_level_when_replying": 2
    },
    "groups": [
        {
            "name": group_name,
            "display_name": display_name
            "automatic_membership_retroactive": false,
            "has_messages": false,
            "bio_raw": null,
            "messageable_level": 0,
            "flair_bg_color": null,
            "incoming_email": null,
            "visibility_level": 0,
            "flair_url": null,
            "id": 1,
            "automatic": true,
            "full_name": null,
            "mentionable_level": 0,
            "public_exit": false,
            "primary_group": false,
            "flair_color": null,
            "grant_trust_level": null,
            "bio_cooked": null,
            "automatic_membership_email_domains": null,
            "membership_request_template": null,
            "public_admission": false,
            "allow_membership_requests": false,
            "title": null,
            "user_count": 1234,
            "default_notification_level": 3
        }
    ],
    "badge_count": 0,
    "can_edit_username": true,
    "can_edit_name": true,
    "gravatar_avatar_template": null,
    "admin": false,
    "last_posted_at": null,
    "can_send_private_messages": true,
    "can_edit_email": true,
    "user_api_keys": null,
    "name": name,
    "profile_view_count": 0,
    "time_read": 0,
    "custom_fields": {},
    "staged": false,
    "created_at": created_at,
    "second_factor_enabled": false,
    "primary_group_flair_color": null,
    "invited_by": null,
    "can_be_deleted": true,
    "primary_group_name": null,
    "system_avatar_upload_id": null,
    "last_seen_at": null,
    "username": username,
    "custom_avatar_upload_id": null,
    "post_count": 0,
    "user_fields": {
        "1": null
    },
    "can_delete_all_posts": true,
    "can_edit": true,
    "has_title_badges": false,
    "card_badge": null,
    "muted_usernames": [],
    "muted_tags": [],
    "system_avatar_template": "",
    "group_users": [
        {
            "user_id": 1234,
            "notification_level": 3,
            "group_id": 1
        }
    ],
    "tracked_tags": [],
    "gravatar_avatar_upload_id": null,
    "avatar_template": "",
    "can_send_private_message_to_user": true,
    "pending_count": 0
}````
`````

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [5월 28, 2018, 8:00오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/4 "2018-05-28T20:00:46Z")

</div>

That looks like the data that’s returned from the regular user route, not the `/admin/users/{user_id}.json` route. To double check, go to the `/admin/users` page on your forum. Click on the username of a user you know has logged in through SSO. On that user’s page, add `.json` to the URL in your browser’s address bar. You should see a json response with a `single_sign_on_record` property.

---

<div class="post-metadata">

### Author: ![henriqueberlesi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/henriqueberlesi/32/119922_2.png) [@henriqueberlesi](https://meta.discourse.org/u/henriqueberlesi)
#### Post date: [5월 29, 2018, 5:08오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/5 "2018-05-29T17:08:56Z")

</div>

> [@simon](#):
>
> On that user’s page, add `.json` to the URL in your browser’s address bar.

Oh, I see!

Using this method I was able to retrieve the proper user information that I was looking for.

Thanks for your help, @simon!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [6월 8, 2024, 12:37오후 UTC](https://meta.discourse.org/t/get-external-id-used-in-sso-through-the-api/88611/6 "2024-06-08T12:37:22Z")

</div>

이 주제는 2202일 후 자동으로 닫혔습니다. 더 이상 새로운 답변을 작성할 수 없습니다.
