tokenIntrospection method

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

Get token details Retrieve information about the provided token.

Parameters:

  • token - The token to be introspected.
  • tokenType - The provided token's type.
  • 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 TokenIntrospect as data Throws DioException if API call or serialization fails

Implementation

Future<Response<TokenIntrospect>> tokenIntrospection({
  String? token,
  String? tokenType,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  const path = r'/oauth2/introspect';
  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 (tokenType != null) r'token_type': encodeQueryParameter(_serializers, tokenType, 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,
  );

  TokenIntrospect? responseData;

  try {
    final rawResponse = response.data;
    responseData = rawResponse == null ? null : _serializers.deserialize(
      rawResponse,
      specifiedType: const FullType(TokenIntrospect),
    ) as TokenIntrospect;

  } catch (error, stackTrace) {
    throw DioException(
      requestOptions: response.requestOptions,
      response: response,
      type: DioExceptionType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<TokenIntrospect>(
    data: responseData,
    headers: response.headers,
    isRedirect: response.isRedirect,
    requestOptions: response.requestOptions,
    redirects: response.redirects,
    statusCode: response.statusCode,
    statusMessage: response.statusMessage,
    extra: response.extra,
  );
}