tokenRevocation method

Future<Response<void>> tokenRevocation({
  1. String? token,
  2. String? clientId,
  3. String? clientSecret,
  4. CancelToken? cancelToken,
  5. Map<String, dynamic>? headers,
  6. Map<String, dynamic>? extra,
  7. ValidateStatus? validateStatus,
  8. ProgressCallback? onSendProgress,
  9. ProgressCallback? onReceiveProgress,
})

Revoke token Revoke a previously issued token.

Parameters:

  • token - The token to be revoked.
  • clientId - The identifier for your client.
  • clientSecret - The secret associated with your client.
  • 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 Throws DioException if API call or serialization fails

Implementation

Future<Response<void>> tokenRevocation({
  String? token,
  String? clientId,
  String? clientSecret,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  const path = r'/oauth2/revoke';
  final options = Options(
    method: r'POST',
    headers: <String, dynamic>{...?headers},
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {'type': 'http', 'scheme': 'bearer', 'name': 'kindeBearerAuth'},
      ],
      ...?extra,
    },
    contentType: 'application/x-www-form-urlencoded',
    validateStatus: validateStatus,
  );

  dynamic bodyData;

  try {
    bodyData = <String, dynamic>{
      if (token != null)
        r'token': encodeQueryParameter(
          _serializers,
          token,
          const FullType(String),
        ),
      if (clientId != null)
        r'client_id': encodeQueryParameter(
          _serializers,
          clientId,
          const FullType(String),
        ),
      if (clientSecret != null)
        r'client_secret': encodeQueryParameter(
          _serializers,
          clientSecret,
          const FullType(String),
        ),
    };
  } catch (error, stackTrace) {
    throw DioException(
      requestOptions: options.compose(_dio.options, path),
      type: DioExceptionType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  final response = await _dio.request<Object>(
    path,
    data: bodyData,
    options: options,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  return response;
}