# Discourse API SSO sync fails to find record

**URL:** https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911
**Category:** Development
**Created:** [2017 年 9 月 12 日午後 6:07 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911 "2017-09-12T18:07:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bufordtaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bufordtaylor/32/120708_2.png) [@bufordtaylor](https://meta.discourse.org/u/bufordtaylor)
#### Post date: [2017 年 9 月 12 日午後 6:07 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/1 "2017-09-12T18:07:00Z")

</div>

I’m attempting to update the email records of a user via the API.

Here’s me finding the record by external\_id:

```plaintext
[20] pry(main)> c.by_external_id("1388")
=> {
                                  "id" => 2,
                            "username" => "Buford_Taylor",

```

Here’s it failing to sync\_sso with that same `external_id`

```plaintext
[21] pry(main)> c.sync_sso(external_id: "1388", sso_secret: ENV['DISCOURSE_SSO_SECRET'])
DiscourseApi::NotFoundError:
from /usr/local/lib/ruby/gems/2.4.0/gems/discourse_api-0.17.0/lib/discourse_api/client.rb:135:in `handle_error'

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017 年 9 月 12 日午後 11:18 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/2 "2017-09-12T23:18:44Z")

</div>

Mail was recently moved to a new one-to-many table setup so that might be impacting you here. The “email” field on the user table doesn’t work any more.

---

<div class="post-metadata">

### Author: ![bufordtaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bufordtaylor/32/120708_2.png) [@bufordtaylor](https://meta.discourse.org/u/bufordtaylor)
#### Post date: [2017 年 9 月 12 日午後 11:21 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/3 "2017-09-12T23:21:16Z")

</div>

Gotcha, but shouldn’t `sync_sso` still be able to find that user by external\_id, especially considering the command prior to it found the user by external\_id?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017 年 9 月 12 日午後 11:26 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/4 "2017-09-12T23:26:45Z")

</div>

Not sure, just offering a possibly related bit of info.

---

<div class="post-metadata">

### Author: ![bufordtaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bufordtaylor/32/120708_2.png) [@bufordtaylor](https://meta.discourse.org/u/bufordtaylor)
#### Post date: [2017 年 9 月 12 日午後 11:37 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/5 "2017-09-12T23:37:45Z")

</div>

Right on.

Poking around the code, I figured it out. It was returning a 404 because I temporarily disabled SSO on my dev discourse server: [discourse/app/controllers/admin/users\_controller.rb at 2f0c6c99e07ae1aa2a7217bdad39e213557c49c2 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/2f0c6c99e07ae1aa2a7217bdad39e213557c49c2/app/controllers/admin/users_controller.rb#L301)

Thanks again @codinghorror

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2017 年 9 月 13 日午前 11:06 UTC](https://meta.discourse.org/t/discourse-api-sso-sync-fails-to-find-record/69911/6 "2017-09-13T11:06:51Z")

</div>


