Angie
Angie

Reputation: 107

OneDrive for Business API item/file download content 401

My question seems similar to OneDrive for Business REST API - PUT,POST - 401 Unauthorized

However, instead of uploading, I am trying to download a file. What's strange is that I do get the file contents and data, but the response code is a 401.

Any idea why? Of course, I would like to be receiving a 200 and not have to ignore the response code.

As far as my Azure AD app permissions go, I am allowing pretty much all read permissions under delegated permissions for Office 365. I have listed all the permissions I selected here, for your reference.

Delegated Permissions I am allowing for Office 365: Read managed metadata Run search queries as a user Read items in all site collections Read user files

Delegated Permissions I am allowing for Windows Azure Active Directory: Enable sign-on and read users' profiles

I have not enabled anything under Application Permissions.

Upvotes: 1

Views: 880

Answers (1)

Ryan Gregg
Ryan Gregg

Reputation: 2035

There is a bug in our implementation - if you provide an Authorization: header with a bearer token on the download URL (which is pre-authenticate) the service rejects the authentication (hence the 401) but since the URL is pre-authenticated, the contents of the file are still sent.

We're working on a fix. You can track the status by watching this issue on our GitHub repo: https://github.com/OneDrive/onedrive-api-docs/issues/189

Upvotes: 0

Related Questions