Skip to content

Commit ceaf712

Browse files
committed
fix sometimes-broken onedrive api calls
* Some OneDrive endpoints return a 401 error if the `Authorization` header is included with a signed request. This depends on the individual host serving the request, but we'll go ahead and turn it off for all. Context: * MS API documentation for chunked_upload requests: https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#remarks * Rclone fix for the upload endpoint: rclone/rclone@dedad9f * Rclone fix for the download endpoint: rclone/rclone@aee8d90 [ENG-7287]
1 parent 1e7df8a commit ceaf712

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tests/providers/onedrive/test_provider.py

-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ async def test_download_standard_file_range(self, provider, download_fixtures):
516516
assert content == b'te'
517517
assert aiohttpretty.has_call(method='GET', uri=download_url,
518518
headers={'Range': 'bytes=0-1',
519-
'Authorization': 'bearer wrote harry potter',
520519
'accept-encoding': ''})
521520

522521
@pytest.mark.asyncio

waterbutler/providers/onedrive/provider.py

+2
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ async def download(self, # type: ignore
310310
'GET',
311311
download_url,
312312
range=range,
313+
no_auth_header=True, # if download_url is signed, OD will sometimes 401 if auth header is included
313314
expects=(HTTPStatus.OK, HTTPStatus.PARTIAL_CONTENT),
314315
headers={'accept-encoding': ''},
315316
throws=exceptions.DownloadError,
@@ -766,6 +767,7 @@ async def _chunked_upload_stream_by_range(self, upload_url, data, start_range=0,
766767
start_range + len(data) - 1,
767768
total_size)
768769
},
770+
no_auth_header=True, # this endpoint will sometimes 401 if the Auth header included
769771
expects=(HTTPStatus.ACCEPTED, HTTPStatus.CREATED),
770772
throws=exceptions.UploadError
771773
)

0 commit comments

Comments
 (0)