The users are able to open sharepoint document locations directly, but when they try to access documents tab, files are not accessible from CRM side:

We have populated also Sharepoint Email Address field, but the problem is still present. The users have all the necessary permisions.
PS. Sharepoint integration is enabled, but the document locations are not created by the out of the box functionality. Custom flow solution is used for creating document locations.
Also if we try to upload some file from CRM side, this error is shown:
The remote server returned a 401 unauthorized error. Please contact your administrator.