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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,829 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,072 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,567 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiajing Hua-MFST 9,260 Reputation points Microsoft Vendor
    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 Answers by the question author, which helps users to know the answer solved the author's problem.