def retry_on_bad_auth(func):
    """If bad token or board, try again after clearing relevant cache entries"""
    @wraps(func)
    def retry_version(self, *args, **kwargs):
        while True:
            try:
                return func(self, *args, **kwargs)
            except trolly.ResourceUnavailable:
                sys.stderr.write('bad request (refresh board id)\n')
                self._board_id = None
                self.save_key('board_id', None)
            except trolly.Unauthorised:
                sys.stderr.write('bad permissions (refresh token)\n')
                self._client = None
                self._token = None
                self.save_key('token', None)
    return retry_version
If bad token or board, try again after clearing relevant cache entries