(
        token,
        secret,
        digest_method=hashlib.sha1,
        token_length=6,
        interval_length=30,
)
return _is_possible_token(
        token,
        token_length=token_length,
    ) and int(token) == get_totp(
        secret,
        digest_method=digest_method,
        token_length=token_length,
        interval_length=interval_length,
    )
Check if given token is valid time-based one-time password for given
    secret.

    :param token: token which is being checked
    :type token: int or str
    :param secret: secret for which the token is being checked
    :type secret: str
    :param digest_method: method of generating digest (hashlib.sha1 by default)
    :type digest_method: callable
    :param token_length: length of the token (6 by default)
    :type token_length: int
    :param interval_length: length of TOTP interval (30 seconds by default)
    :type interval_length: int
    :return: True, if is valid token, False otherwise
    :rtype: bool

    >>> secret = b'MFRGGZDFMZTWQ2LK'
    >>> token = get_totp(secret)
    >>> valid_totp(token, secret)
    True
    >>> valid_totp(token+1, secret)
    False
    >>> token = get_totp(secret, as_string=True)
    >>> valid_totp(token, secret)
    True
    >>> valid_totp(token + b'1', secret)
    False
Check if given token is valid time-based one-time password for given
    secret.
Check if given token is valid time - based one - time password for given secret .
def valid_totp(
        token,
        secret,
        digest_method=hashlib.sha1,
        token_length=6,
        interval_length=30,
):
    """Check if given token is valid time-based one-time password for given
    secret.

    :param token: token which is being checked
    :type token: int or str
    :param secret: secret for which the token is being checked
    :type secret: str
    :param digest_method: method of generating digest (hashlib.sha1 by default)
    :type digest_method: callable
    :param token_length: length of the token (6 by default)
    :type token_length: int
    :param interval_length: length of TOTP interval (30 seconds by default)
    :type interval_length: int
    :return: True, if is valid token, False otherwise
    :rtype: bool

    >>> secret = b'MFRGGZDFMZTWQ2LK'
    >>> token = get_totp(secret)
    >>> valid_totp(token, secret)
    True
    >>> valid_totp(token+1, secret)
    False
    >>> token = get_totp(secret, as_string=True)
    >>> valid_totp(token, secret)
    True
    >>> valid_totp(token + b'1', secret)
    False
    """
    return _is_possible_token(
        token,
        token_length=token_length,
    ) and int(token) == get_totp(
        secret,
        digest_method=digest_method,
        token_length=token_length,
        interval_length=interval_length,
    )
def valid_totp ( token , secret , digest_method = hashlib . sha1 , token_length = 6 , interval_length = 30 , ) : return _is_possible_token ( token , token_length = token_length , ) and int ( token ) == get_totp ( secret , digest_method = digest_method , token_length = token_length , interval_length = interval_length , )