Added central user credentials management

This commit is contained in:
2023-06-11 18:18:37 +02:00
parent 04c244503e
commit 1521056217
22 changed files with 207 additions and 159 deletions

View File

@ -3,19 +3,17 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../model/accountData.dart';
import 'fileSharingApiParams.dart';
class FileSharingApi {
Future<void> share(FileSharingApiParams query) async {
var preferences = await SharedPreferences.getInstance();
Map<String, String> headers = {};
headers.putIfAbsent("Accept", () => "application/json");
headers.putIfAbsent("OCS-APIRequest", () => "true");
Uri endpoint = Uri.https("${preferences.getString("username")!}:${preferences.getString("password")!}@cloud.marianum-fulda.de", "/ocs/v2.php/apps/files_sharing/api/v1/shares", query.toJson().map((key, value) => MapEntry(key, value.toString())));
Uri endpoint = Uri.https("${AccountData().buildHttpAuthString()}@cloud.marianum-fulda.de", "/ocs/v2.php/apps/files_sharing/api/v1/shares", query.toJson().map((key, value) => MapEntry(key, value.toString())));
log("request file share");
Response response = await http.post(endpoint, headers: headers);