Make sure that your application is presenting a valid access token to Microsoft Graph as part of the request. This error often means that the access token may be missing in the HTTP authenticate request header or that the token is invalid or has expired.
We strongly recommend that you use the Microsoft Authentication Library (MSAL) for access token acquisition. Additionally this error may occur, if you try to use a delegated access token granted to a personal Microsoft account, to access an API that only supports work or school accounts (organizational accounts).
You can also check the answers already available on Microsoft Q&A for 401 errors -https://learn.microsoft.com/en-us/answers/search.html?q=%5Bmicrosoft-graph%5D%20401%20&redirect=search%2Fsearch&sort=relevance&type=question%20OR%20idea%20OR%20kbentry%20OR%20answer%20OR%20topic%20OR%20user
Hope this help , Let me know if you have any questions.
Thanks
----------
Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.