rclone: Can't use onedrive on business SharePoint doc library if I don't have read access to the document root

The associated forum post URL from https://forum.rclone.org

As per previous discussion: https://forum.rclone.org/t/cant-ls-onedrive-business-shared-folder-not-in-root-of-drive/19559

What is your current rclone version (output from rclone version)?

v1.57.0

What problem are you are trying to solve?

I’m trying to access a document library of a SharePoint site in my org. The doc library is set up so I don’t have access to list the root folder, only a special folder just for me a few levels deep. This is the same situation as described by someone else in the linked thread.

I can set it up ok, but I can’t list it with rclone: rclone lsd 'MySite:General/akdorsSpecialFolder' first tries to get MySite:General, which is the one I don’t have access to:

rclone -vvv --dump requests lsd 'MySite:General/akdorsSpecialFolder'
<7>DEBUG : GET /v1.0/drives/b!-[CENSORED]/root HTTP/1.1
Host: graph.microsoft.com
User-Agent: rclone/v1.57.0
Authorization: XXXX
Accept-Encoding: gzip

<7>DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<7>DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<7>DEBUG : HTTP RESPONSE (req 0xc000630200)
<7>DEBUG : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-cache
Client-Request-Id: [CENSORED]
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Date: Tue, 25 Jan 2022 08:44:38 GMT
Odata-Version: 4.0
Request-Id: [CENSORED]
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Ms-Ags-Diagnostic: {"ServerInfo":{"DataCenter":"Australia Southeast","Slice":"E","Ring":"4","ScaleUnit":"002","RoleInstance":"[CENSORED]"}}

<7>DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<7>DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<7>DEBUG : HTTP REQUEST (req 0xc000576200)
<7>DEBUG : GET /v1.0/drives/b!-[CENSORED]/items/01[CENSORED]Z:/General: HTTP/1.1
Host: graph.microsoft.com
User-Agent: rclone/v1.57.0
Authorization: XXXX
Accept-Encoding: gzip

<7>DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<7>DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<7>DEBUG : HTTP RESPONSE (req 0xc000576200)
<7>DEBUG : HTTP/1.1 404 Not Found
Transfer-Encoding: chunked
Cache-Control: no-cache
Client-Request-Id: [CENSORED]
Content-Type: application/json
Date: Tue, 25 Jan 2022 08:44:37 GMT
Request-Id: [CENSORED]
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Ms-Ags-Diagnostic: {"ServerInfo":{"DataCenter":"Australia Southeast","Slice":"E","Ring":"4","ScaleUnit":"001","RoleInstance":"[CENSORED]"}}

How do you think rclone should be changed to solve that?

In the linked forum thread, and in comments in the source, it was explained that the traversal design was necessary to find children, as the graph API doesn’t allow getting the id of a driveitem directly by path. While this may have been true at the time, it sems to no longer be the case: I can use the Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) to call

https://graph.microsoft.com/v1.0/drives/b!-[CENSORED]/root:/General/akdorsSpecialFolder

and I get a 200 response. So, maybe rclone doesn’t need to get children at every level from the root anymore? <-- hence, feature request 😃

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don’t comment if you have no relevant information to add. It’s just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Do you know the ID of your folder?

It would be possible to get rclone to use the folder ID directly to access it.

In the linked forum thread, and in comments in the source, it was explained that the traversal design was necessary to find children, as the graph API doesn’t allow getting the id of a driveitem directly by path. While this may have been true at the time, it sems to no longer be the case: I can use the Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) to call

https://graph.microsoft.com/v1.0/drives/b!-[CENSORED]/root:/General/akdorsSpecialFolder

and I get a 200 response. So, maybe rclone doesn’t need to get children at every level from the root anymore? <-- hence, feature request 😃

Hmm, that is a potential speedup for all onedrive users

In theory a change like this would work

https://github.com/rclone/rclone/blob/0eb7b716d9a52af8859c85370465009af119644b/backend/onedrive/onedrive.go#L854-L863

diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go
index 14269f443..887ed7ca6 100644
--- a/backend/onedrive/onedrive.go
+++ b/backend/onedrive/onedrive.go
@@ -852,7 +852,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
 	})
 
 	// Get rootID
-	rootInfo, _, err := f.readMetaDataForPath(ctx, "")
+	rootInfo, _, err := f.readMetaDataForPath(ctx, root)
 	if err != nil {
 		return nil, fmt.Errorf("failed to get root: %w", err)
 	}

Then the directory cache could be initialised with the root found directly rather than traversing the path.

https://github.com/rclone/rclone/blob/0eb7b716d9a52af8859c85370465009af119644b/backend/onedrive/onedrive.go#L694-L695

However readMetaDataForPath uses the directory cache and I don’t think it will work as-is. It’s quite complicated too as it has to deal with shared folders and the differences between…

@Cnly any thoughts about this?