Skip to content

confirm_device async

confirm_device(
    access_token: TokenModelType,
    device_key: DeviceKeyType,
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
    device_secret_verifier_config: Optional[DeviceSecretVerifierConfigType] = None,
    device_name: Optional[DeviceNameType] = None,
) -> ConfirmDeviceResponse

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.

Amazon Cognito doesn't evaluate Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you can't use IAM credentials to authorize requests, and you can't grant IAM permissions in policies. For more information about authorization models in Amazon Cognito, see Using the Amazon Cognito user pools API and user pool endpoints.

Parameters:

  • access_token (TokenModelType) –

    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.

  • device_key (DeviceKeyType) –

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

  • device_secret_verifier_config (Optional[DeviceSecretVerifierConfigType], default: None ) –

    The configuration of the device secret verifier.

  • device_name (Optional[DeviceNameType], default: None ) –

    A friendly name for the device, for example MyMobilePhone.

Raises:

Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
async def confirm_device(
    self,
    access_token: "capo_cognito_identity_provider.types.token_model_type.TokenModelType",
    device_key: "capo_cognito_identity_provider.types.device_key_type.DeviceKeyType",
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
    device_secret_verifier_config: Optional[
        "capo_cognito_identity_provider.types.device_secret_verifier_config_type.DeviceSecretVerifierConfigType"
    ] = None,
    device_name: Optional[
        "capo_cognito_identity_provider.types.device_name_type.DeviceNameType"
    ] = None,
) -> "capo_cognito_identity_provider.types.confirm_device_response.ConfirmDeviceResponse":
    """<p>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 <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-device-tracking.html">Working with user devices in your user pool</a>.</p> <p>Authorize this action with a signed-in user's access token. It must include the scope <code>aws.cognito.signin.user.admin</code>.</p> <note> <p>Amazon Cognito doesn't evaluate Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you can't use IAM credentials to authorize requests, and you can't grant IAM permissions in policies. For more information about authorization models in Amazon Cognito, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html">Using the Amazon Cognito user pools API and user pool endpoints</a>.</p> </note>

    Args:
        access_token: <p>A valid access token that Amazon Cognito issued to the currently signed-in user. Must include a scope claim for <code>aws.cognito.signin.user.admin</code>.</p>
        device_key: <p>The unique identifier, or device key, of the device that you want to update the status for.</p>
        device_secret_verifier_config: <p>The configuration of the device secret verifier.</p>
        device_name: <p>A friendly name for the device, for example <code>MyMobilePhone</code>.</p>

    Raises:
        capo_cognito_identity_provider.errors.device_key_exists_exception.DeviceKeyExistsException: <p>This exception is thrown when a user attempts to confirm a device with a device key that already exists.</p>
        capo_cognito_identity_provider.errors.forbidden_exception.ForbiddenException: <p>This exception is thrown when WAF doesn't allow your request based on a web ACL that's associated with your user pool.</p>
        capo_cognito_identity_provider.errors.internal_error_exception.InternalErrorException: <p>This exception is thrown when Amazon Cognito encounters an internal error.</p>
        capo_cognito_identity_provider.errors.invalid_lambda_response_exception.InvalidLambdaResponseException: <p>This exception is thrown when Amazon Cognito encounters an invalid Lambda response.</p>
        capo_cognito_identity_provider.errors.invalid_parameter_exception.InvalidParameterException: <p>This exception is thrown when the Amazon Cognito service encounters an invalid parameter.</p>
        capo_cognito_identity_provider.errors.invalid_password_exception.InvalidPasswordException: <p>This exception is thrown when Amazon Cognito encounters an invalid password.</p>
        capo_cognito_identity_provider.errors.invalid_user_pool_configuration_exception.InvalidUserPoolConfigurationException: <p>This exception is thrown when the user pool configuration is not valid.</p>
        capo_cognito_identity_provider.errors.not_authorized_exception.NotAuthorizedException: <p>This exception is thrown when a user isn't authorized.</p>
        capo_cognito_identity_provider.errors.operation_not_enabled_exception.OperationNotEnabledException: <p>This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.</p>
        capo_cognito_identity_provider.errors.password_reset_required_exception.PasswordResetRequiredException: <p>This exception is thrown when a password reset is required.</p>
        capo_cognito_identity_provider.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when the Amazon Cognito service can't find the requested resource.</p>
        capo_cognito_identity_provider.errors.too_many_requests_exception.TooManyRequestsException: <p>This exception is thrown when the user has made too many requests for a given operation.</p>
        capo_cognito_identity_provider.errors.username_exists_exception.UsernameExistsException: <p>This exception is thrown when Amazon Cognito encounters a user name that already exists in the user pool.</p>
        capo_cognito_identity_provider.errors.user_not_confirmed_exception.UserNotConfirmedException: <p>This exception is thrown when a user isn't confirmed successfully.</p>
        capo_cognito_identity_provider.errors.user_not_found_exception.UserNotFoundException: <p>This exception is thrown when a user isn't found.</p>
        capo_cognito_identity_provider.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cognito_identity_provider.types.confirm_device_request.ConfirmDeviceRequest]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity_provider.types.confirm_device_response.ConfirmDeviceResponse"
    ]:
        import capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.confirm_device

        (
            output,
            http_response,
        ) = await capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.confirm_device.async_confirm_device(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cognito_identity_provider.types.confirm_device_request.ConfirmDeviceRequest",
    ) -> dict[str, Any]:
        import capo_cognito_identity_provider.types.confirm_device_request

        return capo_cognito_identity_provider.types.confirm_device_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ConfirmDevice", redact_input=_redact_input),
    )
    input_: capo_cognito_identity_provider.types.confirm_device_request.ConfirmDeviceRequest = {
        "access_token": access_token,
        "device_key": device_key,
    }
    if device_secret_verifier_config is not None:
        input_["device_secret_verifier_config"] = device_secret_verifier_config
    if device_name is not None:
        input_["device_name"] = device_name

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output