fix: don't send auth header for resumable upload PUT requests#49
Open
YasharF wants to merge 1 commit into
Open
fix: don't send auth header for resumable upload PUT requests#49YasharF wants to merge 1 commit into
YasharF wants to merge 1 commit into
Conversation
Author
|
This is a potential fix for KoenZomers/KeePassOneDriveSync#180 I don't have access to the different variations of One drive account (i.e. business vs personal) so couldn't fully test it. I think the business end-points might tolerate including the token more often than the personal OneDrive end-points. |
2 tasks
aab803b to
0b79d1b
Compare
That upload URL is a pre-authenticated, opaque URL returned by createUploadSession; per Microsoft Graph's documented contract, it must not receive an Authorization header (the token is already embedded in the URL). Sending one anyway causes the fragment PUT to fail, the loop retries and eventually gives up, UploadFileViaResumableUploadInternal returns null. MaximumBasicFileUploadSizeInBytes = 4 * 1024 routes anything ≤4KB through the simple-upload path (which correctly uses the Bearer token against the real Graph endpoint) and anything larger through this resumable path. Ref doc: https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#remarks 7/13/2026 > If you include the Authorization header when issuing the PUT call, it might result in an HTTP 401 Unauthorized response. Only include the Authorization header and bearer token when issuing the POST request during the first step. Don't include it when issuing the PUT call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
That upload URL is a pre-authenticated, opaque URL returned by createUploadSession; per Microsoft Graph's documented contract, it must not receive an Authorization header (the token is already embedded in the URL). Sending one anyway causes the fragment PUT to fail, the loop retries and eventually gives up, UploadFileViaResumableUploadInternal returns null.
MaximumBasicFileUploadSizeInBytes = 4 * 1024 routes anything ≤4KB through the simple-upload path (which correctly uses the Bearer token against the real Graph endpoint) and anything larger through this resumable path.
Ref doc: https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#remarks 7/13/2026