submitSelfServiceLoginFlow method
Submit a Login Flow :::info This endpoint is EXPERIMENTAL and subject to potential breaking changes in the future. ::: Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows. API flows expect `application/json` to be sent in the body and responds with HTTP 200 and a application/json body with the session token on success; HTTP 302 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors. Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 302 redirect to the post/after login URL or the `return_to` value if it was set and if the login succeeded; a HTTP 302 redirect to the login UI URL with the flow ID containing the validation errors otherwise. Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 302 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors. If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of: `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows. More information can be found at Ory Kratos User Login and User Registration Documentation.
Parameters:
flow
- The Login Flow ID The value for this parameter comes fromflow
URL Query parameter sent to your application (e.g./login?flow=abcde
).xSessionToken
- The Session Token of the Identity performing the settings flow.submitSelfServiceLoginFlowBody
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 SuccessfulSelfServiceLoginWithoutBrowser as data
Throws DioError
if API call or serialization fails
Implementation
Future<Response<SuccessfulSelfServiceLoginWithoutBrowser>> submitSelfServiceLoginFlow({
required String flow,
String? xSessionToken,
SubmitSelfServiceLoginFlowBody? submitSelfServiceLoginFlowBody,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/self-service/login';
final _options = Options(
method: r'POST',
headers: <String, dynamic>{
if (xSessionToken != null) r'X-Session-Token': xSessionToken,
...?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)),
};
dynamic _bodyData;
try {
const _type = FullType(SubmitSelfServiceLoginFlowBody);
_bodyData = submitSelfServiceLoginFlowBody == null ? null : _serializers.serialize(submitSelfServiceLoginFlowBody, 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,
);
SuccessfulSelfServiceLoginWithoutBrowser _responseData;
try {
const _responseType = FullType(SuccessfulSelfServiceLoginWithoutBrowser);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as SuccessfulSelfServiceLoginWithoutBrowser;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<SuccessfulSelfServiceLoginWithoutBrowser>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}