onedrive-uploader icon indicating copy to clipboard operation
onedrive-uploader copied to clipboard

About uploadToSession 401

Open Luoooio opened this issue 8 months ago • 1 comments

It is now June 17, 2024. While using a self-developed upload tool and testing your tool, I discovered that uploading large files using the session endpoint results in a 401 error. After some research, I modified the code in the httpSendFilePart function by commenting out the Authorization part, which made the endpoint work successfully. I speculate that Microsoft standardized the API in June, and when using PUT to the uploadurl, it checks for Authorization. If it exists, the request will fail, although I don't understand the significance of this.

	requestHeaders := make(HTTPRequestParams)
	requestHeaders["Content-Type"] = mimeType
	requestHeaders["Content-Length"] = strconv.FormatInt(n, 10)
	requestHeaders["Content-Range"] = "bytes " + strconv.FormatInt(offset, 10) + "-" + strconv.FormatInt(n+offset-1, 10) + "/" + strconv.FormatInt(fileSize, 10)
	//if client.AccessToken != "" {
	//	requestHeaders["Authorization"] = "Bearer " + client.AccessToken
	//}
	return client.httpRequest(method, uri, requestHeaders, nil, data, progress)
}```

Luoooio avatar Jun 17 '24 05:06 Luoooio