After some testing, I found that the script appears to complete correctly, but the tsv file is empty.
Are you able to print anything to the TSV? Can you try:
print(repsonse.text) or print(response.headers["Link"])
this should give you the json text or the header links for pagination.
Related to the as_user_id: When I use it as you have it in the code, it loads the student's ID in both locations. When I do that in a browser I receive a permissions denied message.
When I have the student's ID in the first location, but mine in the act_as location, I receive a page of 100 results.
Yes, when you use the student's id in both field, it is as if you are using the masquerade function acting as that user. When I do not include the student ID in the act_as location, I am not able to return the next page in the header links/pagination. It will only return first, current, and last.
Is the user you are trying to act as another admin? I receive an error when I try to use another admin with more permissions than me.