Not sure if it’s a copy-paste issue or if your code is really as you show here. If the latter then the problem is you’re using “smart” quotes. If you replace “task_id” with "task_id", it works on my end:
from pymatgen.ext.matproj import MPRester
data = MPRester().query(criteria={}, properties=["task_id"])