Nextcloud version (eg, 18.0.2): 20.0.0 stable
Operating system and version (eg, Ubuntu 20.04): Plesk
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18.0-v.debian.9+p18.0.30.0+t200826.0942
PHP version (eg, 7.1): 7.4
The issue you are facing:
I always get an error when I try to create a user with the user provisioning API in nodejs
Is this the first time you’ve seen this error? (Y/N): N
Steps to replicate it:
- Create the code
- Run the desired action to create a user
- See the error in console
My nodejs logs:
statusCode: 401
<?xml version="1.0"?>
<ocs>
<meta>
<status>failure</status>
<statuscode>997</statuscode>
<message>Current user is not logged in</message>
<totalitems></totalitems>
<itemsperpage></itemsperpage>
</meta>
<data/>
</ocs>
The output of your config.php file in /path/to/nextcloud
(make sure you remove any identifiable information!):
<?php
$CONFIG = array (
'passwordsalt' => 'removed',
'secret' => 'removed',
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'cloud.infinity-systems.eu',
),
'datadirectory' => '/var/www/vhosts/1850.webhost-02.my-host.network/.nextcloud/data/0a6811a1c3f9',
'dbtype' => 'mysql',
'version' => '20.0.0.9',
'overwrite.cli.url' => 'http://localhost',
'dbname' => 'nextcloud_5d62f30d',
'dbhost' => 'localhost:3306',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'ncuser_5d62f30d',
'dbpassword' => 'removed',
'installed' => true,
'instanceid' => 'occfdylare55',
'mail_smtpmode' => 'smtp',
'mail_smtpauthtype' => 'LOGIN',
'mail_sendmailmode' => 'smtp',
'mail_smtpauth' => 1,
'mail_from_address' => 'no-reply',
'mail_domain' => 'infinity-systems.eu',
'mail_smtphost' => 'webhost-02.my-host.network',
'mail_smtpport' => '25',
'mail_smtpname' => 'no-reply@infinity-systems.eu',
'mail_smtppassword' => 'removed',
);
The output of your Apache/nginx/system log in /var/log/____
:
2020-10-10 13:42:50 162.158.158.13 401 POST /ocs/v1.php/cloud/users HTTP/1.1
The nodejs code I use to create the user:
const https = require('https')
const message = removed
const user = removed
const pw = removed
const data = JSON.stringify({
userid: user,
password: pw,
})
const options = {
hostname: 'cloud.infinity-systems.eu',
baseURL: 'https://cloud.infinity-systems.eu/ocs/v1.php/cloud/',
url: 'cloud.infinity-systems.eu',
path: '/ocs/v1.php/cloud/users',
method: 'POST',
headers: {
'OCS-APIRequest': 'true',
'Authorization': 'Basic "Base64(removed:removed)"',
'Content-Type': 'application/x-www-form-urlencoded',
},
}
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', (d) => {
process.stdout.write(d)
})
})
req.on('error', (error) => {
console.error(error)
})
req.write(data)
req.end()