Closed ElectrifyPowr closed 1 year ago
It's currently not possible, but one could implement this endpoint: https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/instruction_set_for_users.html
I got it to work with the http package like the following:
import 'package:http/http.dart' as http;
//...
username = "Frank";
password = "frankspassw";
String displayName = "Frank Test";
String email = "frank@email.com";
/// where 'admin' is username of an admin & 'secret' is password of admin
final auth = "admin:secret";
final baseUrl = "example.com"; //url of your NextCloud
// following example taken from documentation:
//curl -X POST http://admin:secret@example.com/ocs/v1.php/cloud/users -d userid="Frank" -d password="frankspassw"
var apiCall = 'https://$auth@$baseUrl/ocs/v1.php/cloud/users?';
Map<String, String> queryParams = {
'userid': username,
'password': password,
'displayName': displayName,
'email': email,
'format': 'json',//not necessary if you want to get response in XML
};
var headers = {
"OCS-APIRequest": "true", //required header
};
String queryString = Uri(queryParameters: queryParams).query;
var requestUrl = apiCall + queryString; // adds parameters to API call
http.Response response = await http.post(Uri.parse(requestUrl), headers: headers);
Feel free to implement it in this package. You can take a look at the other clients/endpoints to see how the current structure works.
Since I am on a deadline I probably won't have the time, but I also looked deeper into the source code of the package and I agree that it shouldn't be too hard to implement this into the plugin 👍
Ok :)
But still this is a valid feature request so I'll re-open this
Hi, when creating an instance of
NextCloudClient
I can log in as user. However, I would also like to create users with this Dart Plugin.How would that be possible?