The 401 error should be caused by you using the client credential flow. The api endpoint currently only supports Tasks.Read
delegated permissions, so you need to log in with an Azure AD work account and use the auth code flow to obtain a token.
By the way, the api endpoint does not support personal Microsoft accounts. If your account is an Azure AD account, then it is a work account, so it works fine.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.