deleteDevices method
This API endpoint uses the User-Interactive Authentication API, except when used by an application service.
Deletes the given devices, and invalidates any access token associated with them.
WARNING: When this endpoint requires User-Interactive Authentication, it cannot be used when the access token was obtained via the OAuth 2.0 API.
WARNING:
Added in `v1.18` OAuth 2.0 aware clients
MUST NOT use this endpoint when the server supports the OAuth 2.0 API.
Instead they MUST refer the user to the account management URL,
if available.
auth Additional authentication information for the
user-interactive authentication API.
devices The list of device IDs to delete.
Implementation
Future<void> deleteDevices(
List<String> devices, {
AuthenticationData? auth,
}) async {
final requestUri = Uri(path: '_matrix/client/v3/delete_devices');
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(
jsonEncode({
if (auth != null) 'auth': auth.toJson(),
'devices': devices.map((v) => v).toList(),
}),
);
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return ignore(json);
}