getKnowledgeConnectorsByProviderCallback method
CompleteConnectorOAuth finishes an OAuth connection: it exchanges the provider's code for a token, seals that token in KMS, and records the connection.
CompleteConnectorOAuth finishes an OAuth connection: it exchanges the provider's code for a token, seals that token in KMS, and records the connection. THE ORG COMES FROM THE SIGNED STATE, not from a header and not from the provider, so an attacker cannot bind their own account to someone else's org — a tampered, expired or foreign-provider state is refused outright. The token itself is never returned, never written into the document, and never logged; the document holds only its KMS path.
Parameters:
-
String provider (required): Provider is the connector completing its flow, from the path.
-
String code: Code is the provider's authorization code, exchanged for a token.
-
String state: State is the org-bound value this server signed at connect time.
-
String error: Error is the provider's denial reason when the user refused consent.
Implementation
Future<ConnectionOut?> getKnowledgeConnectorsByProviderCallback(String provider, { String? code, String? state, String? error, }) async {
final response = await getKnowledgeConnectorsByProviderCallbackWithHttpInfo(provider, code: code, state: state, error: error, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ConnectionOut',) as ConnectionOut;
}
return null;
}