This error is mainly caused if in your login request, the resource parameter is not https://graph.microsoft.com
The response should be:
For more information:https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=python#response
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".