# Programmatically create user with OAuth2 user ID

**URL:** <https://meta.discourse.org/t/programmatically-create-user-with-oauth2-user-id/196920>\
**Category:** Product Support\
**Created:** [July 12, 2021, 11:26pm UTC](https://meta.discourse.org/t/programmatically-create-user-with-oauth2-user-id/196920 "2021-07-12T23:26:39Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![gnuletik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gnuletik/32/227434_2.png) [@gnuletik](https://meta.discourse.org/u/gnuletik)\
**Post date:** [July 13, 2021, 1:15pm UTC](https://meta.discourse.org/t/programmatically-create-user-with-oauth2-user-id/196920/4 "2021-07-13T13:15:12Z")

</div>

I would think of exposing the `associated_accounts` like this when creating a new user :

```json
POST /users.json
{
  username: "something",
  email: "test@test.com",
  associated_accounts: [
    {
      provider_name: "oauth2_basic",
      provider_uid: "12345"
    }
  ]
}

```

This would be perfect !

Note: this is similar to the `provider` and `extern_uid` parameters of Gitlab Users API ([Users API | GitLab Docs](https://docs.gitlab.com/ee/api/users.html#user-creation))

---

_[View the full topic](https://meta.discourse.org/t/programmatically-create-user-with-oauth2-user-id/196920)._
