updateOAuthClient method

Future<Map<String, dynamic>> updateOAuthClient(
  1. String projectId,
  2. String clientId, {
  3. List<String>? grantTypes,
  4. List<String>? responseTypes,
  5. List<String>? redirectUris,
  6. String? scope,
  7. Map<String, dynamic>? metadata,
})

PUT /accounts/projects/{project_id}/oauth/clients/{client_id} Body: any subset of { grant_types, response_types, redirect_uris, scope, metadata } Returns a small status JSON (e.g., { "ok": true }).

Implementation

Future<Map<String, dynamic>> updateOAuthClient(
  String projectId,
  String clientId, {
  List<String>? grantTypes,
  List<String>? responseTypes,
  List<String>? redirectUris,
  String? scope,
  Map<String, dynamic>? metadata,
}) async {
  final cid = Uri.encodeComponent(clientId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/oauth/clients/$cid');

  final body = <String, dynamic>{};
  if (grantTypes != null) body['grant_types'] = grantTypes;
  if (responseTypes != null) body['response_types'] = responseTypes;
  if (redirectUris != null) body['redirect_uris'] = redirectUris;
  if (scope != null) body['scope'] = scope;
  if (metadata != null) body['metadata'] = metadata;

  final response = await http.put(uri, headers: _getHeaders(), body: jsonEncode(body));

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to update OAuth client. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  return jsonDecode(response.body) as Map<String, dynamic>;
}