createProjectExternalOAuthRegistration method
Future<String>
createProjectExternalOAuthRegistration({
- required String projectId,
- required OAuthClientConfig oauth,
- required String clientId,
- String? clientSecret,
- String? delegatedTo,
- ConnectorRef? connector,
Implementation
Future<String> createProjectExternalOAuthRegistration({
required String projectId,
required OAuthClientConfig oauth,
required String clientId,
String? clientSecret,
String? delegatedTo,
ConnectorRef? connector,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/external-oauth');
final body = <String, dynamic>{
'oauth': oauth.toJson(),
'client_id': clientId,
if (clientSecret != null) 'client_secret': clientSecret,
if (delegatedTo != null) 'delegated_to': delegatedTo,
if (connector != null) 'connector': connector.toJson(),
};
final response = await httpClient.post(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to create project external oauth registration. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return (jsonDecode(response.body) as Map<String, dynamic>)['id'] as String;
}