OneDrive API returns 401 for some users when downloading files

David Brownell 20 Reputation points
2024-08-07T16:24:10.2566667+00:00

I wrote a script to download pictures from OneDrive. This script works well for one user. However, the same script returns a 401 error when attempting to download files using the url specified by @microsoft.graph.downloadUrl. What is strange is that I don't receive an unauthorized error when enumerating the files, it is only when attempting to download the files using the information provided during enumeration.

In digging into the problem, I noticed that the urls returned for the user that works are different from the urls returned for the user that receives the unauthorized errors:

Working urls start with https://rpgpbw.by.files.1drv.com while urls that receive the unauthorized errors start with https://my.microsoftpersonalcontent.com.

Do you have any idea of what might be different between these 2 accounts?

Thanks in advance for the help!

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | OneDrive | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jiajing Hua 18,125 Reputation points Moderator
    2024-08-08T02:51:48.04+00:00

    Hi @David Brownell

    Since your issue is more related to OneDrive Development, I suggest you post a new thread in Microsoft Tech Community --- OneDrive Developer.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    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.



0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.