OneDrive - auto-renew access token doesn't work

What is the problem you are having with rclone?

When I setup or renew OneDrive (Global, Personal) I only get an access token for 1h.
Contrary to @ncw's statement apparently rclone doesn't auto-renew it as it reproducible runs into

2023/03/29 05:38:40 DEBUG : [file n]: Unchanged skipping
2023/03/29 05:38:40 DEBUG : [file n+1]: Size and modification time the same (differ by 0s, within tolerance 1s)
2023/03/29 05:38:40 DEBUG : [file n+2]: Unchanged skipping
2023/03/29 05:38:40 ERROR : [file n+3]: error reading destination directory: couldn't list files: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.
2023/03/29 05:38:40 ERROR : [file n+4]: error reading destination directory: couldn't list files: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.
2023/03/29 05:38:40 ERROR : [file n+5]: error reading destination directory: couldn't list files: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.

Run the command 'rclone version' and share the full output of the command.

rclone v1.62.0

  • os/version: Microsoft Windows 10 Pro 20H2 (64 bit)
  • os/kernel: 10.0.19042.1202 Build 19042.1202.1202 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone sync S: OneDrive:

The rclone config contents with secrets removed.

[OneDrive]
type = onedrive
region = global
token = {"access_token":"Ew[snipped]or","expiry":"2023-03-29T06:41:51.5998802+02:00"}
drive_id = 5[snipped]9
drive_type = personal

A log from the command with the -vv flag

2023/03/29 06:34:25 DEBUG : rclone: Version "v1.62.0" starting with parameters ["rclone" "sync" "S:" "OneDrive:" "-vv"]
2023/03/29 06:34:25 DEBUG : Creating backend with remote "S:"
2023/03/29 06:34:27 DEBUG : Creating backend with remote "OneDrive:"
[...]
2023/03/29 06:41:33 INFO  : [file n]: Copied (new)
2023/03/29 06:41:33 INFO  : [file n+1]: Copied (new)
2023/03/29 06:41:33 INFO  : [file n+2]: Copied (new)
2023/03/29 06:41:33 DEBUG : [file n+3]: Starting multipart upload
2023/03/29 06:41:34 DEBUG : [file n+4]: Starting multipart upload
2023/03/29 06:41:34 ERROR : [file n+3]: Failed to copy: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.
2023/03/29 06:41:34 ERROR : [file n+4]: Failed to copy: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.
2023/03/29 06:41:34 DEBUG : [file n+5]: Starting multipart upload
2023/03/29 06:41:34 ERROR : [file n+5]: Failed to copy: InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.
[...]
2023/03/29 06:42:00 INFO  : Signal received: interrupt

You don't have a refresh_token in here - it should have a "refresh_token":"M.[snip]", part in it.

I don't know why that should be though...

Running rclone reconnect OneDrive: should be enough to renew the token and give you a refresh token.

Does that work?

1 Like

I found the issue: rclone.conf was r/o.
Works great for Koofr and pCloud, quite obviously doesn't work for OneDrive.

Feature request:
Please do more detailled error reporting in debug mode (in this case "write error [errno] to rclone.conf" or alike or just print out whatever the OS reports back to rclone).
It made debugging the setup much easier.

.
For others finding this thread:
Also make sure you have access to (ATM, 2023/03/29)

13.107.42.0/24
20.190.159.0/24
20.190.160.0/24
40.126.32.0/24
45.131.244.0/24
116.202.160.0/24

(these are the ranges I needed to open to setup and renew access tokens for OneDrive global (region option 1 in rclone config OneDrive setup))

It already logs errors if it can't write.

may be but it did not in my case.
no error message at all except the

InvalidAuthenticationToken: CompactToken validation failed with reason code: 80049228.

messages

That's not a debug log and that's the single error line.

You'd have gotten a permission denied.

rclone about GD: -vv
2023/03/29 11:31:37 DEBUG : Setting --config "/home/felix/rclone.conf" from environment variable RCLONE_CONFIG="/home/felix/rclone.conf"
2023/03/29 11:31:37 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "about" "GD:" "-vv"]
2023/03/29 11:31:37 DEBUG : Creating backend with remote "GD:"
2023/03/29 11:31:37 Failed to load config file "/home/felix/rclone.conf": open /home/felix/rclone.conf: permission denied

Dunno why you insist when I told you "I haven't"?

That's too late as the refresh token was already not there and it was 'broken' at that point.

I'm not insisting anything as I can only go based on what information is shared.

2023/03/29 11:58:29 DEBUG : Failed to keep previous owner of config file: chown /home/felix/rclone.conf824508635: operation not permitted

It's easy to recreate the issue with making it read only.

I would have hoped Rclone would have produced an ERROR log in this case. Possibly this happened while you were doing the rclone config maybe?

How was the config file read only? Is it chmod read only or owned by another user or on a read only filing system or something else?

rclone.conf was on a r/o file system.
rclone.conf is in my primary cloud storage and I use a high-bandwidth VPS (off site, 3rd parties could access it, so I deem it a 'not trustworthy environment') to replicate it to secondary and tertiary CS.

To protect my primary CS the VPS only has r/o access. I created/renewed the OneDrive token from home.
Now I mounted a separate folder of primary CS as r/w drive to host rclone.conf and it works like a charm.

I tried this on a read only file system (made with mount bind -o ro) to see exactly what rclone does.

$ rclone lsf onedrive: -vv --config /mnt/tmp/.rclone.conf
2023/03/30 16:41:30 DEBUG : rclone: Version "v1.63.0-beta.6930.75e385bc4" starting with parameters ["rclone" "lsf" "onedrive:" "-vv" "--config" "/mnt/tmp/.rclone.conf"]
2023/03/30 16:41:30 DEBUG : Creating backend with remote "onedrive:"
2023/03/30 16:41:30 DEBUG : Using config file from "/mnt/tmp/.rclone.conf"
2023/03/30 16:41:30 DEBUG : onedrive: Loaded invalid token from config file - ignoring
2023/03/30 16:41:31 DEBUG : Saving config "token" in section "onedrive" of the config file
2023/03/30 16:41:37 ERROR : Failed to save config after 10 tries: failed to create temp file for new config: open /mnt/tmp/.rclone.conf1771939521: read-only file system
2023/03/30 16:41:37 DEBUG : onedrive: Saved new token in config file

So rclone will have made an ERROR log with a pretty good message.

Rclone doesn't consider this worth returning a non-zero exit code - maybe it should? Would that have helped you @rcRsc ?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.