testInvokeAuthorizer method

Future<TestInvokeAuthorizerResponse> testInvokeAuthorizer({
  1. required String authorizerName,
  2. HttpContext? httpContext,
  3. MqttContext? mqttContext,
  4. TlsContext? tlsContext,
  5. String? token,
  6. String? tokenSignature,
})

Tests a custom authorization behavior by invoking a specified custom authorizer. Use this to test and debug the custom authorization behavior of devices that connect to the AWS IoT device gateway.

May throw ResourceNotFoundException. May throw InvalidRequestException. May throw ThrottlingException. May throw UnauthorizedException. May throw ServiceUnavailableException. May throw InternalFailureException. May throw InvalidResponseException.

Parameter authorizerName : The custom authorizer name.

Parameter httpContext : Specifies a test HTTP authorization request.

Parameter mqttContext : Specifies a test MQTT authorization request.

Parameter tlsContext : Specifies a test TLS authorization request.

Parameter token : The token returned by your custom authentication service.

Parameter tokenSignature : The signature made with the token and your custom authentication service's private key. This value must be Base-64-encoded.

Implementation

Future<TestInvokeAuthorizerResponse> testInvokeAuthorizer({
  required String authorizerName,
  HttpContext? httpContext,
  MqttContext? mqttContext,
  TlsContext? tlsContext,
  String? token,
  String? tokenSignature,
}) async {
  ArgumentError.checkNotNull(authorizerName, 'authorizerName');
  _s.validateStringLength(
    'authorizerName',
    authorizerName,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'token',
    token,
    1,
    6144,
  );
  _s.validateStringLength(
    'tokenSignature',
    tokenSignature,
    1,
    2560,
  );
  final $payload = <String, dynamic>{
    if (httpContext != null) 'httpContext': httpContext,
    if (mqttContext != null) 'mqttContext': mqttContext,
    if (tlsContext != null) 'tlsContext': tlsContext,
    if (token != null) 'token': token,
    if (tokenSignature != null) 'tokenSignature': tokenSignature,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/authorizer/${Uri.encodeComponent(authorizerName)}/test',
    exceptionFnMap: _exceptionFns,
  );
  return TestInvokeAuthorizerResponse.fromJson(response);
}