createSelfServiceLogoutFlowUrlForBrowsers method

Future<Response<SelfServiceLogoutUrl>> createSelfServiceLogoutFlowUrlForBrowsers({
  1. String? cookie,
  2. CancelToken? cancelToken,
  3. Map<String, dynamic>? headers,
  4. Map<String, dynamic>? extra,
  5. ValidateStatus? validateStatus,
  6. ProgressCallback? onSendProgress,
  7. ProgressCallback? onReceiveProgress,
})

Create a Logout URL for Browsers This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user. This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token. The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error. When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.

Parameters:

  • cookie - HTTP Cookies If you call this endpoint from a backend, please include the original Cookie header in the request.
  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a SelfServiceLogoutUrl as data Throws DioError if API call or serialization fails

Implementation

Future<Response<SelfServiceLogoutUrl>> createSelfServiceLogoutFlowUrlForBrowsers({
  String? cookie,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/self-service/logout/browser';
  final _options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      if (cookie != null) r'cookie': cookie,
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final _response = await _dio.request<Object>(
    _path,
    options: _options,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  SelfServiceLogoutUrl _responseData;

  try {
    const _responseType = FullType(SelfServiceLogoutUrl);
    _responseData = _serializers.deserialize(
      _response.data!,
      specifiedType: _responseType,
    ) as SelfServiceLogoutUrl;

  } catch (error, stackTrace) {
    throw DioError(
      requestOptions: _response.requestOptions,
      response: _response,
      type: DioErrorType.other,
      error: error,
    )..stackTrace = stackTrace;
  }

  return Response<SelfServiceLogoutUrl>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}