rejectOAuth2ConsentRequest method

Future<Response<OAuth2RedirectTo>> rejectOAuth2ConsentRequest({
  1. required String consentChallenge,
  2. RejectOAuth2Request? rejectOAuth2Request,
  3. CancelToken? cancelToken,
  4. Map<String, dynamic>? headers,
  5. Map<String, dynamic>? extra,
  6. ValidateStatus? validateStatus,
  7. ProgressCallback? onSendProgress,
  8. ProgressCallback? onReceiveProgress,
})

Reject OAuth 2.0 Consent Request When an authorization code, hybrid, or implicit OAuth 2.0 Flow is initiated, Ory asks the login provider to authenticate the subject and then tell Ory now about it. If the subject authenticated, he/she must now be asked if the OAuth 2.0 Client which initiated the flow should be allowed to access the resources on the subject's behalf. The consent challenge is appended to the consent provider's URL to which the subject's user-agent (browser) is redirected to. The consent provider uses that challenge to fetch information on the OAuth2 request and then tells Ory if the subject accepted or rejected the request. This endpoint tells Ory that the subject has not authorized the OAuth 2.0 client to access resources on his/her behalf. The consent provider must include a reason why the consent was not granted. The response contains a redirect URL which the consent provider should redirect the user-agent to. The default consent provider is available via the Ory Managed Account Experience. To customize the consent provider, please head over to the OAuth 2.0 documentation.

Parameters:

  • consentChallenge - OAuth 2.0 Consent Request Challenge
  • rejectOAuth2Request
  • 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 OAuth2RedirectTo as data Throws DioError if API call or serialization fails

Implementation

Future<Response<OAuth2RedirectTo>> rejectOAuth2ConsentRequest({
  required String consentChallenge,
  RejectOAuth2Request? rejectOAuth2Request,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/admin/oauth2/auth/requests/consent/reject';
  final _options = Options(
    method: r'PUT',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[],
      ...?extra,
    },
    contentType: 'application/json',
    validateStatus: validateStatus,
  );

  final _queryParameters = <String, dynamic>{
    r'consent_challenge': encodeQueryParameter(_serializers, consentChallenge, const FullType(String)),
  };

  dynamic _bodyData;

  try {
    const _type = FullType(RejectOAuth2Request);
    _bodyData = rejectOAuth2Request == null ? null : _serializers.serialize(rejectOAuth2Request, specifiedType: _type);

  } catch(error, stackTrace) {
    throw DioError(
       requestOptions: _options.compose(
        _dio.options,
        _path,
        queryParameters: _queryParameters,
      ),
      type: DioErrorType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

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

  OAuth2RedirectTo? _responseData;

  try {
    final rawResponse = _response.data;
    _responseData = rawResponse == null ? null : _serializers.deserialize(
      rawResponse,
      specifiedType: const FullType(OAuth2RedirectTo),
    ) as OAuth2RedirectTo;

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

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