Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Hi dragon
Thank you for reaching out to Microsoft Q&A Forum and sharing your experience.
A 401 error when downloading a OneDrive file typically indicates an issue with the access token configuration. Please verify: Is your app single-tenant or multi-tenant?
- For single-tenant apps, please consider using the tenant-specific authority:
https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token - And set:
scope = https://graph.microsoft.com/.default - Validate the JWT via https://jwt.ms:
aud = https://graph.microsoft.com(Note: Microsoft is providing this information as a convenience to you. This site is not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link). - For delegated permissions:
scpincludesFiles.Read,Files.Read.All, or broader likeFiles.ReadWrite.All. - For app-only permissions:
rolesincludesFiles.Read.AllorSites.Selected(with granted site-level permission). -
issmatches your tenant authority:https://sts.windows.net/{tenant-guid}/ -
expis in the future (token not expired).
Please let me know how you get on, as your feedback is valuable to the community.
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.