getAuthMetadata method

Future<GetAuthMetadataResponse> getAuthMetadata()

Gets the OAuth 2.0 authorization server metadata, as defined in RFC 8414, including the endpoint URLs and the supported parameters that can be used by the clients.

This endpoint definition includes only the fields that are meaningful in the context of the Matrix specification. The full list of possible fields is available in the OAuth Authorization Server Metadata registry, and normative definitions of them are available in their respective RFCs.

NOTE: The authorization server metadata is relatively large and may change over time. Clients should:

  • Cache the metadata appropriately based on HTTP caching headers
  • Refetch the metadata if it is stale

Implementation

Future<GetAuthMetadataResponse> getAuthMetadata() async {
  final requestUri = Uri(path: '_matrix/client/v1/auth_metadata');
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  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 GetAuthMetadataResponse.fromJson(json as Map<String, Object?>);
}