Skip to content

verify_user_attribute async

verify_user_attribute(
    access_token: TokenModelType,
    attribute_name: AttributeNameType,
    code: ConfirmationCodeType,
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
) -> VerifyUserAttributeResponse

Submits a verification code for a signed-in user who has added or changed a value of an auto-verified attribute. When successful, the user's attribute becomes verified and the attribute email_verified or phone_number_verified becomes true.

If your user pool requires verification before Amazon Cognito updates the attribute value, this operation updates the affected attribute to its pending value.

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.

  • attribute_name (AttributeNameType) –

    The name of the attribute that you want to verify.

  • code (ConfirmationCodeType) –

    The verification code that your user pool sent to the added or changed attribute, for example the user's email address.

Raises:

  • AliasExistsException –

    This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias.

  • CodeMismatchException –

    This exception is thrown if the provided code doesn't match what the server was expecting.

  • ExpiredCodeException –

    This exception is thrown if a code has expired.

  • ForbiddenException –

    This exception is thrown when WAF doesn't allow your request based on a web ACL that's associated with your user pool.

  • InternalErrorException –

    This exception is thrown when Amazon Cognito encounters an internal error.

  • InvalidParameterException –

    This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

  • LimitExceededException –

    This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.

  • NotAuthorizedException –

    This exception is thrown when a user isn't authorized.

  • OperationNotEnabledException –

    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.

  • PasswordResetRequiredException –

    This exception is thrown when a password reset is required.

  • ResourceNotFoundException –

    This exception is thrown when the Amazon Cognito service can't find the requested resource.

  • TooManyRequestsException –

    This exception is thrown when the user has made too many requests for a given operation.

  • UserNotConfirmedException –

    This exception is thrown when a user isn't confirmed successfully.

  • UserNotFoundException –

    This exception is thrown when a user isn't found.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
async def verify_user_attribute(
    self,
    access_token: "capo_cognito_identity_provider.types.token_model_type.TokenModelType",
    attribute_name: "capo_cognito_identity_provider.types.attribute_name_type.AttributeNameType",
    code: "capo_cognito_identity_provider.types.confirmation_code_type.ConfirmationCodeType",
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
) -> "capo_cognito_identity_provider.types.verify_user_attribute_response.VerifyUserAttributeResponse":
    """<p>Submits a verification code for a signed-in user who has added or changed a value of an auto-verified attribute. When successful, the user's attribute becomes verified and the attribute <code>email_verified</code> or <code>phone_number_verified</code> becomes <code>true</code>.</p> <p> If your user pool requires verification before Amazon Cognito updates the attribute value, this operation updates the affected attribute to its pending value.</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>
        attribute_name: <p>The name of the attribute that you want to verify.</p>
        code: <p>The verification code that your user pool sent to the added or changed attribute, for example the user's email address.</p>

    Raises:
        capo_cognito_identity_provider.errors.alias_exists_exception.AliasExistsException: <p>This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias.</p>
        capo_cognito_identity_provider.errors.code_mismatch_exception.CodeMismatchException: <p>This exception is thrown if the provided code doesn't match what the server was expecting.</p>
        capo_cognito_identity_provider.errors.expired_code_exception.ExpiredCodeException: <p>This exception is thrown if a code has expired.</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_parameter_exception.InvalidParameterException: <p>This exception is thrown when the Amazon Cognito service encounters an invalid parameter.</p>
        capo_cognito_identity_provider.errors.limit_exceeded_exception.LimitExceededException: <p>This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.</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.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.verify_user_attribute_request.VerifyUserAttributeRequest]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity_provider.types.verify_user_attribute_response.VerifyUserAttributeResponse"
    ]:
        import capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.verify_user_attribute

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

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

        return capo_cognito_identity_provider.types.verify_user_attribute_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("VerifyUserAttribute", redact_input=_redact_input),
    )
    input_: capo_cognito_identity_provider.types.verify_user_attribute_request.VerifyUserAttributeRequest = {
        "access_token": access_token,
        "attribute_name": attribute_name,
        "code": code,
    }

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