@classmethod
def find(cls, db, token, *, kind=None):
    """Find a token object by value.

        Returns None if not found.

        `kind='user'` only returns API tokens for users
        `kind='service'` only returns API tokens for services
        """
    prefix_match = cls.find_prefix(db, token)
    if kind == 'user':
        prefix_match = prefix_match.filter(cls.user_id != None)
    elif kind == 'service':
        prefix_match = prefix_match.filter(cls.service_id != None)
    elif kind is not None:
        raise ValueError("kind must be 'user', 'service', or None, not %r" %
            kind)
    for orm_token in prefix_match:
        if orm_token.match(token):
            return orm_token
