Closed markuskreusch closed 7 years ago
@markuskreusch, Thanks for your contribution. To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.
It will cover your contributions to all Microsoft-managed open source projects. Thanks, Microsoft Pull Request Bot
@markuskreusch, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.
Thanks, Microsoft Pull Request Bot
This is due to an inconsistency in the way that OneDrive accepts headers between Personal and Business accounts. We have implemented a solution in .NET here. I'll look into the best way to solve this in Android and get back to you.
Thanks for the PR. We are going to implement another fix for this as documented in issue #45, which will allow users to send session requests without the header. This has been put on our backlog; in the meantime, feel free to use the workaround you have implemented above.
When doing chunked uploads I repeatedly got 401 unauthorized responses from the server. This seems to be by design and is documented here: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/item_createuploadsession#upload-bytes-to-the-upload-session (at the end of the notes section).
Had a look at the code and found out the header is added by default to every request in DefaultHttpProvider#sendRequestInternal through the registered IAuthenticationAdapter (MSAAuthAndroidAdapter in our case). Because the IAuthenticationAdapter should/can not know about URLs/request patterns which require that authentication must be ommited I decided to fix it in the request implementation.
I am not really happy with the current solution but introducing AuthorizationHeaderOmittingHeaderOptionList was the only way to prevent addition of the header by other implementations of IAuthenticationAdapter through the modifiable reference to the HeaderOption list returned by BaseRequest#getHeaders (which may or may not exist). I am willing to fix it another way if you give me some hints.