submitSelfServiceVerificationFlow method
- required String flow,
- String? token,
- SubmitSelfServiceVerificationFlowBody? submitSelfServiceVerificationFlowBody,
- CancelToken? cancelToken,
- Map<
String, dynamic> ? headers, - Map<
String, dynamic> ? extra, - ValidateStatus? validateStatus,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
Complete Verification Flow Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states: `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 302 Found redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 302 Found redirect to the Verification UI URL with the Verification Flow ID appended. `sent_email` is the success state after `choose_method` when using the `link` method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow ("sending a verification link") does not have any API capabilities. The server responds with a HTTP 302 Found redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an error message that the verification link was invalid. More information can be found at Ory Kratos Email and Phone Verification Documentation.
Parameters:
flow
- The Verification Flow ID The value for this parameter comes fromflow
URL Query parameter sent to your application (e.g./verification?flow=abcde
).token
- Verification Token The verification token which completes the verification request. If the token is invalid (e.g. expired) an error will be shown to the end-user. This parameter is usually set in a link and not used by any direct API call.submitSelfServiceVerificationFlowBody
cancelToken
- ACancelToken
that can be used to cancel the operationheaders
- Can be used to add additional headers to the requestextras
- Can be used to add flags to the requestvalidateStatus
- AValidateStatus
callback that can be used to determine request success based on the HTTP status of the responseonSendProgress
- AProgressCallback
that can be used to get the send progressonReceiveProgress
- AProgressCallback
that can be used to get the receive progress
Returns a Future containing a Response
with a SelfServiceVerificationFlow as data
Throws DioError
if API call or serialization fails
Implementation
Future<Response<SelfServiceVerificationFlow>> submitSelfServiceVerificationFlow({
required String flow,
String? token,
SubmitSelfServiceVerificationFlowBody? submitSelfServiceVerificationFlowBody,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/self-service/verification';
final _options = Options(
method: r'POST',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'flow': encodeQueryParameter(_serializers, flow, const FullType(String)),
if (token != null) r'token': encodeQueryParameter(_serializers, token, const FullType(String)),
};
dynamic _bodyData;
try {
const _type = FullType(SubmitSelfServiceVerificationFlowBody);
_bodyData = submitSelfServiceVerificationFlowBody == null ? null : _serializers.serialize(submitSelfServiceVerificationFlowBody, specifiedType: _type);
} catch(error, stackTrace) {
throw DioError(
requestOptions: _options.compose(
_dio.options,
_path,
queryParameters: _queryParameters,
),
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
final _response = await _dio.request<Object>(
_path,
data: _bodyData,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
SelfServiceVerificationFlow _responseData;
try {
const _responseType = FullType(SelfServiceVerificationFlow);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as SelfServiceVerificationFlow;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<SelfServiceVerificationFlow>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}