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 cid = Uri.encodeComponent(clientId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$projectId/oauth/clients/$cid');

  final response = await http.get(uri, headers: _getHeaders());

  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));
}