# How to seed local database with SSO user data

**URL:** https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210
**Category:** Development
**Created:** [November 21, 2016, 7:09pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210 "2016-11-21T19:09:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 21, 2016, 7:09pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210/1 "2016-11-21T19:09:41Z")

</div>

I’ve got a client that I’m doing an import for. They’re using SSO, which will supply avatars, but of course those get populated only when someone logs in. I noticed `client.sync_sso` and it appears to do just what I need. I think I’d like to do this from the API, but rails console would be fine too.

I thought that `client.sync_sso` would work, but it appears to **push** SSO data, not **pull** SSO data.

Is there some way that I can suck down the SSO data for each user? It doesn’t look like the API will help, maybe something in the console? Looks like `lookup_or_create_user` might help, but I can’t find the `external_id`.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 21, 2016, 7:16pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210/2 "2016-11-21T19:16:06Z")

</div>

I have done exactly this.

What I did was getting the user database, and created all the users using the API.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 21, 2016, 7:19pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210/3 "2016-11-21T19:19:09Z")

</div>

That sounds like what I’m looking for @Falco. Are you saying that I should create all the users from the API before I run the import script that creates the users, or that I should somehow use an API call in the import script to create the user?

Can you point me to some code?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 21, 2016, 7:28pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210/4 "2016-11-21T19:28:39Z")

</div>

I would create the users during the import, and set the avatar at import time also.

You need to ask for a dump that also contains avatars urls.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 21, 2016, 7:34pm UTC](https://meta.discourse.org/t/how-to-seed-local-database-with-sso-user-data/53210/5 "2016-11-21T19:34:04Z")

</div>

I believe I have the URLs. Since avatars get populated when someone logs in, I was thinking that I could use the API (or console) to suck them down from SSO. The importers I’d looked at were uploading the avatars (which I don’t have), but now I see that I can pass a `avatar_url` to `create_users`, which should solve my problem.

Thanks.
