# Using the API to create a user on an SSO only system

**URL:** https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184
**Category:** Support
**Created:** [22 يونيو 2016، 12:51م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184 "2016-06-22T12:51:31Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [22 يونيو 2016، 12:51م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/1 "2016-06-22T12:51:31Z")

</div>

Is it possible to create users via the API with disable local login and SSO enabled?

I’m getting error 500 in response to my API REST calls. other functions work fine.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [22 يونيو 2016، 3:28م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/2 "2016-06-22T15:28:52Z")

</div>

No, SSO disables user creation.

Why do you want to create the users? With SSO, they will be created automatically when they try to log in.

---

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [22 يونيو 2016، 3:42م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/3 "2016-06-22T15:42:53Z")

</div>

I’m migrating a bunch of users who currently use yahoo email groups to message.

I’ve lists of their email addresses and want to add them to a set of Discourse groups. Obviously, I can’t till they log in.

So far I’ve had people complaining that they can’t see their private category when they register, as they are not a member of the group yet. If I could create them as users and assign them to the relevant groups first, it would make it a lot easier!

---

<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: [22 يونيو 2016، 10:14م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/4 "2016-06-22T22:14:08Z")

</div>

These should be staged users, as that’s the purpose of staging a user – participation in prior emails that may or may not turn into a web login.

---

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [23 يونيو 2016، 6:56ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/5 "2016-06-23T06:56:14Z")

</div>

Ahh. How do I do that?

---

<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: [23 يونيو 2016، 6:58ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/6 "2016-06-23T06:58:46Z")

</div>

Let’s ask @zogstrip!

---

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [23 يونيو 2016، 7:01ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/7 "2016-06-23T07:01:46Z")

</div>

I have the same use case as this topic: [Adding new users vs inviting them - #3 by bbendick](https://meta.discourse.org/t/adding-new-users-vs-inviting-them/39422/3)

---

<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: [23 يونيو 2016، 10:29ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/8 "2016-06-23T10:29:09Z")

</div>

Creating staged users using the API is now possible 🌳

[https://github.com/discourse/discourse/commit/5bfc9cf69ede127460bc14d1c7f109841d4e8dee](https://github.com/discourse/discourse/commit/5bfc9cf69ede127460bc14d1c7f109841d4e8dee)  
&nbsp;  
[https://github.com/discourse/discourse\_api/commit/8cfff42d2853c54b7140b2a1fab211ef9cbcbf3b](https://github.com/discourse/discourse_api/commit/8cfff42d2853c54b7140b2a1fab211ef9cbcbf3b)

---

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [23 يونيو 2016، 11:14ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/9 "2016-06-23T11:14:06Z")

</div>

Thank you!

So I would call create user with name, email, password, username, active = false, staged = true?

---

<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: [23 يونيو 2016، 12:42م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/10 "2016-06-23T12:42:08Z")

</div>

That’s right 👍

---

<div class="post-metadata">

### Author: ![Alexander\_Wright](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander_wright/32/119518_2.png) [@Alexander\_Wright](https://meta.discourse.org/u/Alexander_Wright)
#### Post date: [3 يوليو 2016، 12:09م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/11 "2016-07-03T12:09:30Z")

</div>

Right, this is working on a development site that does not have SSO switched on, but fails as soon as it is.  
Should I be trying to do this a different way? Via a plugin, maybe?

---

<div class="post-metadata">

### Author: ![Rana\_Muhammad\_Ahsan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rana_muhammad_ahsan/32/64094_2.png) [@Rana\_Muhammad\_Ahsan](https://meta.discourse.org/u/Rana_Muhammad_Ahsan)
#### Post date: [12 أبريل 2017، 10:25ص UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/12 "2017-04-12T10:25:12Z")

</div>

@Alexander_Wright how did you solve this problem ?

---

<div class="post-metadata">

### Author: ![DylannCordel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanncordel/32/109596_2.png) [@DylannCordel](https://meta.discourse.org/u/DylannCordel)
#### Post date: [24 أغسطس 2018، 3:38م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/13 "2018-08-24T15:38:49Z")

</div>

Hi !

@zogstrip Seems we still can’t create new users via API (Forbidden is returned) with those settings:

- SSO activated
- allow new registrations: enabled (to be able to create account via API)
- invite only: enabled (to disable the “register” button on the forum)
- enable local logins: disabled (to only login via the SSO)

But if “enable local logins” is enabled, then it’s possible to create a new user via the API.

@Rana_Muhammad_Ahsan to temporary solve this problem, I send a PUT request to enable “local logins” setting, then a POST to create the user, then a new PUT request to disable “local logins” setting. Pretty much ugly but working 🙈

---

<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: [24 أغسطس 2018، 4:09م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/15 "2018-08-24T16:09:12Z")

</div>

عند تمكين SSO، يمكنك إنشاء مستخدمين عبر واجهة برمجة التطبيقات باستخدام مسار `sync_sso`. راجع [Sync DiscourseConnect user data with the sync\_sso route](https://meta.discourse.org/t/sync-sso-user-data-with-the-sync-sso-route/84398) للحصول على تفاصيل حول كيفية القيام بذلك.

---

<div class="post-metadata">

### Author: ![DylannCordel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanncordel/32/109596_2.png) [@DylannCordel](https://meta.discourse.org/u/DylannCordel)
#### Post date: [24 أغسطس 2018، 4:56م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/16 "2018-08-24T16:56:29Z")

</div>

@simon awsome ! Thanks a lot.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [8 أبريل 2021، 9:08م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/17 "2021-04-08T21:08:11Z")

</div>



---

<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: [8 أبريل 2021، 10:00م UTC](https://meta.discourse.org/t/using-the-api-to-create-a-user-on-an-sso-only-system/46184/18 "2021-04-08T22:00:32Z")

</div>


