unbind3pidFromAccount method
- String address,
- ThirdPartyIdentifierMedium medium, {
- String? idServer,
Removes a user's third-party identifier from the provided identity server without removing it from the homeserver.
Unlike other endpoints, this endpoint does not take an id_access_token
parameter because the homeserver is expected to sign the request to the
identity server instead.
address
The third-party address being removed.
idServer
The identity server to unbind from. If not provided, the homeserver
MUST use the id_server
the identifier was added through. If the
homeserver does not know the original id_server
, it MUST return
a id_server_unbind_result
of no-support
.
medium
The medium of the third-party identifier being removed.
returns id_server_unbind_result
:
An indicator as to whether or not the identity server was able to unbind
the 3PID. success
indicates that the identity server has unbound the
identifier whereas no-support
indicates that the identity server
refuses to support the request or the homeserver was not able to determine
an identity server to unbind from.
Implementation
Future<IdServerUnbindResult> unbind3pidFromAccount(
String address,
ThirdPartyIdentifierMedium medium, {
String? idServer,
}) async {
final requestUri = Uri(path: '_matrix/client/v3/account/3pid/unbind');
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(
jsonEncode({
'address': address,
if (idServer != null) 'id_server': idServer,
'medium': medium.name,
}),
);
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 IdServerUnbindResult.values
.fromString(json['id_server_unbind_result'] as String)!;
}