confirmDevice method

Future<ConfirmDeviceResponse> confirmDevice({
  1. required String accessToken,
  2. required String deviceKey,
  3. String? deviceName,
  4. DeviceSecretVerifierConfigType? deviceSecretVerifierConfig,
})

Confirms a device that a user wants to remember. A remembered device is a "Remember me on this device" option for user pools that perform authentication with the device key of a trusted device in the back end, instead of a user-provided MFA code. For more information about device authentication, see Working with user devices in your user pool.

Authorize this action with a signed-in user's access token. It must include the scope aws.cognito.signin.user.admin.

May throw DeviceKeyExistsException. May throw ForbiddenException. May throw InternalErrorException. May throw InvalidLambdaResponseException. May throw InvalidParameterException. May throw InvalidPasswordException. May throw InvalidUserPoolConfigurationException. May throw NotAuthorizedException. May throw OperationNotEnabledException. May throw PasswordResetRequiredException. May throw ResourceNotFoundException. May throw TooManyRequestsException. May throw UsernameExistsException. May throw UserNotConfirmedException. May throw UserNotFoundException.

Parameter accessToken : A valid access token that Amazon Cognito issued to the currently signed-in user. Must include a scope claim for aws.cognito.signin.user.admin.

Parameter deviceKey : The unique identifier, or device key, of the device that you want to update the status for.

Parameter deviceName : A friendly name for the device, for example MyMobilePhone.

Parameter deviceSecretVerifierConfig : The configuration of the device secret verifier.

Implementation

Future<ConfirmDeviceResponse> confirmDevice({
  required String accessToken,
  required String deviceKey,
  String? deviceName,
  DeviceSecretVerifierConfigType? deviceSecretVerifierConfig,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.ConfirmDevice'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    signed: false,
    // TODO queryParams
    headers: headers,
    payload: {
      'AccessToken': accessToken,
      'DeviceKey': deviceKey,
      if (deviceName != null) 'DeviceName': deviceName,
      if (deviceSecretVerifierConfig != null)
        'DeviceSecretVerifierConfig': deviceSecretVerifierConfig,
    },
  );

  return ConfirmDeviceResponse.fromJson(jsonResponse.body);
}