Endpoint to create users OCIS

Hi,

Migrating to OCIS from ownCloud server and went through the Docker Container Setup. I used to be able to create users like:

    let storageData = new FormData();
    storageData.append("userid", email);
    storageData.append("password", password);

    await axios.post(storageUrl + "/ocs/v1.php/cloud/users", storageData, {
      auth: {
        username: process.env.ADMIN_USERNAME,
        password: process.env.ADMIN_PASSWORD,
      },
      headers: storageData.getHeaders(),
    });

But doing the same on my OCIS setup return a 401. How can I create users via an api with OCIS?

Assuming you use internal idp that would be a POST request to https://<server-url>/graph/v1.0/users
see ms graph spec for details: Create User - Microsoft Graph v1.0 | Microsoft Learn

Ok, tried that and got a 401, might be that I need an access token, any idea how to obtain one in oCIS?

curl -k -i -XPOST "https://localhost:9200/graph/v1.0/users" -d'{"displayName":"Alice Hansen","mail":"alice@example.org","onPremisesSamAccountName":"alice","passwordProfile":{"password":"1234"}}' -u admin:password
HTTP/1.1 401 Unauthorized
Www-Authenticate: Bearer realm="localhost:9200", charset="UTF-8"
X-Request-Id: 1ab3afc5569f/4KU04OtP27-000292
Date: Fri, 27 Oct 2023 11:43:28 GMT
Content-Length: 0

EDIT: Got it to work with PROXY_ENABLE_BASIC_AUTH set to true

Yes. That is a “workaround”

Basic Auth is not supported for production use. It makes ocis very slow.

I see, what would you suggest so I can make api calls to graph service without basic auth?

Edit: Actually, I am trying to to replace the need to call ocis to create users. See Configure custom IDP for oCIS.

I see, what would you suggest so I can make api calls to graph service without basic auth?

Not quite easy. You’d need to obtain a bearer token and keep it refreshed.