Hi anonymous user
Per your description, The issue is about Authentication. You can check if the code return 401 or 403. For 401 Unauthorized error, Please make sure that your application is presenting a valid access token to Microsoft Graph as part of the request. For 403 Forbidden error, Please make sure that you have enough permission to the graph api you call.
Please check the steps in the following document
https://learn.microsoft.com/en-us/graph/resolve-auth-errors
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.