getOAuthClient method

Future<OAuthClient> getOAuthClient(
  1. String projectId,
  2. String clientId
)

GET /accounts/projects/{project_id}/oauth/clients/{client_id} Returns one OAuthClient (no secret). 404 -> NotFoundException.

Implementation

Future<OAuthClient> getOAuthClient(String projectId, String clientId) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedClientId = Uri.encodeComponent(clientId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/oauth/clients/$encodedClientId');

  final response = await httpClient.get(uri);

  if (response.statusCode == 404) {
    throw NotFoundException('oauth client not found');
  }

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to get OAuth client. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }

  return OAuthClient.fromJson(jsonDecode(response.body));
}