Google Drive Token expires after an hour

That's good advice. Maybe google has put a shadow ban on that client_id or something like that. Google moves in mysterious ways that we mortals can only guess at!

Hi, Ole,

Thank you.

rclone config reconnect name_of_your_remote:

root@Nas_TT:~# rclone config reconnect gdplex:
Already have a token - refresh?
y) Yes (default)
n) No
y/n> 

Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No
y/n> n

Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
	rclone authorize "drive" "eyJjbGllbnRfaWQiOiIxMDQ0MTA4MTk3OTgtYjhiM2YwcGRuZm41Z3VicDJhMXN1cGo1a2hqYW05dHQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJjbGllbnRfc2VjcmV0IjoiR09DU1BYLVdsc1ptTkNSZUNJaUN4c3hFTllMN05lMHl3MXciLCJzY29wZSI6ImRyaXZlIiwidGVhbV9kcml2ZSI6IjBBRUhvVGhKUnBLQWdVazlQVkEifQ"
Then paste the result.
Enter a value.
config_token> {"access_token":"******X9GBdUFUIk6hNKSIYkdZtb5Pi6m1KMTazmchNB2Xpvs9S088rqO86fFFz-swEF9Ey1_L-w3Ct7HRfLqM07t2voUQ6yUhNJb5_040Fb4zpZx6213IHGPzF97z9cfFW12maGDTA4mAR8-FvtJHXlWqC9iSv07aCgYKAcMSARMSFQHUCsbC6O_FTnmUBDCDQ5h9kqvusQ0163","token_type":"Bearer","refresh_token":"1//0giOcDdcatAEXCgYIARAAGBASNwF-L9IrkER_3GWxN5ysJH2qVl5gRm8Mi58SKi29KN6-42DKa5gle-xCcu5GCAKvcgzHDBu7t6w","expiry":"2023-01-17T21:09:57.209498+08:00"}

Change current Shared Drive (Team Drive) ID "****oThJRpKAgUk9PVA"?

y) Yes
n) No (default)
y/n> 


rclone config show name_of_your_remote:

root@Nas_TT:~# rclone config show gdplex:
[gdplex]
type = drive
client_id = ******8b3f0pdnfn5gubp2a1supj5khjam9tt.apps.googleusercontent.com
client_secret = ********ZmNCReCIiCxsxENYL7Ne0yw1w
scope = drive
token = {"access_token":"ya29.a0AX9GBdUFUIk6hNKSIYkdZtb5Pi6m1KMTazmchNB2Xpvs9S088rqO86fFFz-swEF9Ey1_L-w3Ct7HRfLqM07t2voUQ6yUhNJb5_040Fb4zpZx6213IHGPzF97z9cfFW12maGDTA4mAR8-FvtJHXlWqC9iSv07aCgYKAcMSARMSFQHUCsbC6O_FTnmUBDCDQ5h9kqvusQ0163","token_type":"Bearer","refresh_token":"1//0giOcDdcatAEXCgYIARAAGBASNwF-L9IrkER_3GWxN5ysJH2qVl5gRm8Mi58SKi29KN6-42DKa5gle-xCcu5GCAKvcgzHDBu7t6w","expiry":"2023-01-17T21:09:57.209498+08:00"}
team_drive = ****HoThJRpKAgUk9PVA
root_folder_id = 

rclone lsd name_of_your_remote: -vv

root@Nas_TT:~# rclone lsd gdplex: -vv
2023/01/17 20:15:57 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/17 20:15:57 DEBUG : Creating backend with remote "gdplex:"
2023/01/17 20:15:57 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/17 20:15:58 DEBUG : 4 go routines active

After 8hours
rclone lsd name_of_your_remote: -vv

xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/18 07:56:10 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/18 07:56:10 DEBUG : Creating backend with remote "gdplex:"
2023/01/18 07:56:10 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
2023/01/18 07:56:10 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 07:56:10 DEBUG : gdplex: Token refresh failed try 1/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:11 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 07:56:11 DEBUG : gdplex: Token refresh failed try 2/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:12 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 07:56:12 DEBUG : gdplex: Token refresh failed try 3/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:13 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 07:56:13 DEBUG : gdplex: Token refresh failed try 4/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:14 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 07:56:14 DEBUG : gdplex: Token refresh failed try 5/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:15 ERROR : : error listing: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/18 07:56:15 DEBUG : 4 go routines active
2023/01/18 07:56:15 Failed to lsd with 2 errors: last error was: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}

You want to hit no and get a new token and not that you already have one.

Best bet would be to make a whole new remote.

well, because the web browser cannot get the new token automatically, so I have to mannually get new one instead of in the same command window.

Regarding to the whole new now, I tried many times before, no any difference. :frowning:

No idea that means. Find a machine with a working browser and do the process end to end. You can copy the contents over.

You have a process issue somewhere so not sure where then. If you are using the default rclone client ID and could sign up, that shouldn't expire in an hour.

The NAS doesn't have web browser access, so probably following remote_setup/#configuring-using-rclone-authorize

I agree about falling back to remote_setup/#configuring-by-copying-the-config-file, but there are some things I would like to check/ensure first.

The first lsd is executed as root, the second is executed as xiaopaul. The users may see different versions of rclone and different config files (both containing gdplex), which may explain your issue. Please don't try to fix now, that will blur my picture of the situation, just follow my steps until we are sure everything is fixed.

I would like you to post the redacted output from these commands executed as xiaopaul:

which rclone
rclone config file
rclone config show gdplex:

I would like you to post the redacted output from these commands executed as root:

which rclone
rclone config file
rclone config show gdplex:
rclone lsd gdplex: -vv

Hi, Ole,

Thank you.

Wow, I notice that there different client ID & secret as xiaopaul & root. What is wrong?

AS xiaopaul

xiaopaul@Nas_TT:~$ which rclone
/bin/rclone
xiaopaul@Nas_TT:~$ rclone config file
Configuration file is stored at:
/var/services/homes/xiaopaul/.config/rclone/rclone.conf
xiaopaul@Nas_TT:~$ rclone config show gdplex:
[gdplex]
type = drive
client_id = ****222318-62eueh1bjtgftjjcoude7g5ahomj4i2t.apps.googleusercontent.com
client_secret =****PX-_ecDQfrqJbA3sjUFnN8wDQDPrQNr
scope = drive
token = {"access_token":"ya29.a0AX9GBdXuahDxm6V3v0w897ILkXsGziVM3uoELsk2tKWriQu8Ui2aTdC9spFbRtokPjZeaQ6-AaTePHi72bX_Yv2H2TNnQuz-aafEcdPdbqRPaoeQtvYFMOx6mD-W-eJqzJAvakYbHz-MIzP_ARR5uRJIM07KaCgYKAYASARMSFQHUCsbCSxILk4hMyLvInS9S3VWSwQ0163","token_type":"Bearer","refresh_token":"1//0gJV5ZaXlaDXmCgYIARAAGBASNwF-L9IrMhWIgNMuz-a16fr4AYEaTcYJCa6TyIHgHNzFLvRw30_LUC-bI50VaVuLNkRKsc0lc-0","expiry":"2023-01-17T09:55:13.897266+08:00"}
team_drive = 0AEHoThJRpKAgUk9PVA
root_folder_id =

As root:

root@Nas_TT:~# which rclone
/bin/rclone
root@Nas_TT:~# rclone config file
Configuration file is stored at:
/root/.config/rclone/rclone.conf
root@Nas_TT:~# rclone config show gdplex:
[gdplex]
type = drive
client_id = ****819798-b8b3f0pdnfn5gubp2a1supj5khjam9tt.apps.googleusercontent.com
client_secret = ****PX-WlsZmNCReCIiCxsxENYL7Ne0yw1w
scope = drive
token = {"access_token":"ya29.a0AX9GBdUFUIk6hNKSIYkdZtb5Pi6m1KMTazmchNB2Xpvs9S088rqO86fFFz-swEF9Ey1_L-w3Ct7HRfLqM07t2voUQ6yUhNJb5_040Fb4zpZx6213IHGPzF97z9cfFW12maGDTA4mAR8-FvtJHXlWqC9iSv07aCgYKAcMSARMSFQHUCsbC6O_FTnmUBDCDQ5h9kqvusQ0163","token_type":"Bearer","refresh_token":"1//0giOcDdcatAEXCgYIARAAGBASNwF-L9IrkER_3GWxN5ysJH2qVl5gRm8Mi58SKi29KN6-42DKa5gle-xCcu5GCAKvcgzHDBu7t6w","expiry":"2023-01-17T21:09:57.209498+08:00"}
team_drive = 0AEHoThJRpKAgUk9PVA
root_folder_id =
root@Nas_TT:~# rclone lsd gdplex: -vv
2023/01/18 20:28:29 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/18 20:28:29 DEBUG : Creating backend with remote "gdplex:"
2023/01/18 20:28:29 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/01/18 20:28:30 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 20:28:30 DEBUG : gdplex: Token refresh failed try 1/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:31 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 20:28:31 DEBUG : gdplex: Token refresh failed try 2/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:32 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 20:28:32 DEBUG : gdplex: Token refresh failed try 3/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:33 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 20:28:33 DEBUG : gdplex: Token refresh failed try 4/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:34 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/18 20:28:34 DEBUG : gdplex: Token refresh failed try 5/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:35 ERROR : : error listing: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
2023/01/18 20:28:35 DEBUG : 4 go routines active
2023/01/18 20:28:35 Failed to lsd with 2 errors: last error was: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}

That's your process problem.

Rclone is per user so if you change something for one user, it doesn't impact the other user.

So if you changed root's config but are using the other user, it won't work.

Pick one user and use that one all the way. Most people don't run rclone as root but that's a choice you'd have to make.

We haven't payed enough attention to the linux user and client ID used in your configuration flow, which can happen when things doesn't work as expected and many people are involved.

This is the timeline I can see from you logs:

The user xiaopaul has a user specific config stored here:

It contains a remote named gdplex: using this client ID:

where the token was last refreshed yesterday morning:

The user root has another user specific config stored here:

It also has a remote named gdplex: but using another client ID:

where the token was last refreshed yesterday evening:

This client ID appears to have been deleted either entirely or just from having access to your GD sometime between yesterday evening and todays evening:

This last human error is most likely the cause of the error you see when using root today :cry:

This is quite a mess and indicates a lot of frustrated/hectic activity.

I therefore suggest we slow down and take it all in small verified steps.

The first step is to clean up, so we avoid getting confused by old/invalid configs and Client IDs when trying to make a new setup.

First delete any old Client ID's in your Google API Console, so you only have one, and preferably the one we used with root yesterday, that is this one:

Next, log in as root and delete gdplex: in roots config.

Next, log in as xiaopaul and delete gdplex: in xiaopauls config.

Next, delete gdplex: in the config on the PC you have used to do the authorizations, if created there.

Finally, create gdplex: on the PC used to make the authorizations, this should be possible to do with a YES to this question:

and then verify the config and client by executing this on the PC:

and then post the redacted output, so I can follow your progress.

When confirmed we will move on to create a config on your NAS.

Thank you very much, Ole.

First delete any old Client ID's in your Google API Console, so you only have one, and preferably the one we used with root yesterday, that is this one:

I am sorry I have delet the client id before:****819798-b8b3f0pdnfn5gubp2a1supj5khjam9tt.apps.googleusercontent.com.
May I use the one: ****222318-62eueh1bjtgftjjcoude7g5ahomj4i2t.apps.googleusercontent.com
Or, create new one?

AS Root

root@Nas_TT:~# rclone config
Current remotes:

Name                 Type
====                 ====
Alshar               webdav
gdplex               drive
oplex                onedrive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> d

Select remote.
Choose a number from below, or type in an existing value.
 1 > Alshar
 2 > gdplex
 3 > oplex
remote> 2


Current remotes:

Name                 Type
====                 ====
Alshar               webdav
oplex                onedrive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> d

Select remote.
Choose a number from below, or type in an existing value.
 1 > Alshar
 2 > oplex
remote> 1


Current remotes:

Name                 Type
====                 ====
oplex                onedrive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> d

Select remote.
Choose a number from below, or type in an existing value.
 1 > oplex
remote> 1


No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> q
root@Nas_TT:~# exit

AS xiaopaul

xiaopaul@Nas_TT:~$ rclone config
Current remotes:

Name                 Type
====                 ====
gdplex               drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> d

Select remote.
Choose a number from below, or type in an existing value.
 1 > gdplex
remote> 1


No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> q

Next, delete gdplex: in the config on the PC you have used to do the authorizations, if created there.

I only make in my Nas, so there are not gdplex: on my PC.

Finally, create gdplex: on the PC used to make the authorizations, this should be possible to do with a YES to this question:

Yes. Done.

Verify the config

H:\rclone>rclone config show gdplex:
[gdplex]
type = drive
client_id = ****222318-62eueh1bjtgftjjcoude7g5ahomj4i2t.apps.googleusercontent.com
client_secret = ****PX-_ecDQfrqJbA3sjUFnN8wDQDPrQNr
scope = drive
token = {"access_token":"ya29.a0AX9GBdWjLu0N1xOHZkIRrrqtke64J_oCAZi8Lq-wimJGb-KN8gQzSVWyUKIEHy-Swm0Kdk-7POde_S9X18jUvEXw8KDCodv4oe0ko8F4ZaI7nfS9sgR9G6ZHoL4GjVy8AQJhso_xfUi6oPSO_rNg6PZIVzWLaCgYKARQSARMSFQHUCsbC_dWawfhP56rKG4USLuu7Ig0163","token_type":"Bearer","refresh_token":"1//0g6xltqv6To96CgYIARAAGBASNwF-L9IrChUXLcbUFs805mpDYmaYeoKDUHTm6ZFxkh315iBF6Sdi8pfbD1mNkOJqK_4zcaKGBVQ","expiry":"2023-01-19T09:44:36.092439+08:00"}
team_drive = 0AEHoThJRpKAgUk9PVA
root_folder_id =

H:\rclone>rclone lsd gdplex: -vv
2023/01/19 08:47:05 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/19 08:47:05 DEBUG : Creating backend with remote "gdplex:"
2023/01/19 08:47:05 DEBUG : Using config file from "C:\\Users\\xiaop\\AppData\\Roaming\\rclone\\rclone.conf"
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/19 08:47:05 DEBUG : 4 go routines active

H:\rclone>

After 1 Hour

H:\rclone>rclone lsd gdplex: -vv
2023/01/19 10:15:22 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/19 10:15:22 DEBUG : Creating backend with remote "gdplex:"
2023/01/19 10:15:22 DEBUG : Using config file from "C:\\Users\\xiaop\\AppData\\Roaming\\rclone\\rclone.conf"
2023/01/19 10:15:22 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 10:15:23 DEBUG : Saving config "token" in section "gdplex" of the config file
2023/01/19 10:15:23 DEBUG : Keeping previous permissions for config file: -rw-rw-rw-
2023/01/19 10:15:23 DEBUG : gdplex: Saved new token in config file
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/19 10:15:23 DEBUG : 6 go routines active

Great, looks good Xiao!

We now know that your Client ID ending with "4i2t" is correctly refreshing and saving tokens:

Just to make absolutely sure that it also works after a refresh and some additional hours, please try this on your PC:

rclone config show name_of_your_remote:
rclone lsd name_of_your_remote: -vv

No need to post the output, if no errors.

Time to try the same on the NAS.

Here I am missing some details to understand you setup, especially which user we should use to make it fit your setup.

So a first a few questions:

How do you start your mount? (startup script, systemd or ?)
Which user is executing the mount command? (root or xiaopaul?)
What mount command and parameters do you use?
If your setup is inspired by someone else (e.g. https://github.com/animosity22/homescripts) then please link
Something you would like to change in your setup?

If you are sure about the user to use for your mount and the above extra test on the PC went well:

Login on the NAS as the selected user and create the remote like you have done before, please post the redacted output so I can folow your steps.

Next time for the verification, I guess you know the steps:

When confirmed we will move on to configure/start your mount.

Hi, Ole,

Yes. Thank you very much. I think it should befine.

Regarding to your question:

How do you start your mount? (startup script, systemd or ?)

A; Startup scritp.

Which user is executing the mount command? (root or xiaopaul?)

A; xiaopaul

What mount command and parameters do you use?If your setup is inspired by someone else (e.g. [GitHub - animosity22/homescripts: My Scripts for Plex / Emby with Dropbox and rclone ]then please link

Actually, I have not idea about this. I just like to mount the Google drive to my Nas to access file easily. Sometimes I can use Plex to watch some video in that. May I use following as /volume2/Backup/MountCache

rclone mount gdplex:/ /volume1/GDrive/O.plex --buffer-size 32M --vfs-cache-mode minimal --vfs-cache-max-size 4G --vfs-read-chunk-size 64M --dir-cache-time 72h --allow-other --allow-non-empty --fast-list --use-mmap -log-level INFO ----cache-dir=/volume2/Backup/MountCache --daemon

Something you would like to change in your setup?
A: No idea. I just want it can work.

xiaopaul@Nas_TT:~$ rclone config show gdplex:
[gdplex]
type = drive
client_id = ****222318-62eueh1bjtgftjjcoude7g5ahomj4i2t.apps.googleusercontent.com
client_secret = ****PX-_ecDQfrqJbA3sjUFnN8wDQDPrQNr
scope = drive
token = {"access_token":"ya29.a0AX9GBdUDtN-zjT8841QNB0J6P8rouEnWc9LFPA0fRfMnZ19Brsh2mozfencfBau_cEXp4rQRhezGYT1JuZUVsmZaLpKUbkiKDx7lep7dojS-6QKny59pxqEAm-eCfhajpNHBLGbSJrAPSckOkQOJDKwAgNicaCgYKATYSARMSFQHUCsbCCBzKLXwXwe_cOKRQwiQDCw0163","token_type":"Bearer","refresh_token":"1//0gtBaMoisp5qHCgYIARAAGBASNwF-L9IrrjkBhTRTvZb7TolYe158AnvACr0ZJVT28Q8o_USYCUiW1P0SNvhtkJ7dQkvFgH_4BgI","expiry":"2023-01-19T22:04:45.8191932+08:00"}
team_drive = 0AEHoThJRpKAgUk9PVA
root_folder_id =
xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/19 21:06:56 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/19 21:06:56 DEBUG : Creating backend with remote "gdplex:"
2023/01/19 21:06:56 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/19 21:06:57 DEBUG : 4 go routines active
xiaopaul@Nas_TT:~$

After 1 hour

xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/19 22:53:23 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/19 22:53:23 DEBUG : Creating backend with remote "gdplex:"
2023/01/19 22:53:23 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
2023/01/19 22:53:23 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 22:53:24 DEBUG : gdplex: Token refresh failed try 1/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:25 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 22:53:25 DEBUG : gdplex: Token refresh failed try 2/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:26 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 22:53:26 DEBUG : gdplex: Token refresh failed try 3/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:27 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 22:53:27 DEBUG : gdplex: Token refresh failed try 4/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:28 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 22:53:28 DEBUG : gdplex: Token refresh failed try 5/5: oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:29 ERROR : : error listing: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
2023/01/19 22:53:29 DEBUG : 4 go routines active
2023/01/19 22:53:29 Failed to lsd with 2 errors: last error was: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?alt=json&corpora=drive&driveId=0AEHoThJRpKAgUk9PVA&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CexplicitlyTrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%2CshortcutDetails%2CexportLinks%2CresourceKey%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%270AEHoThJRpKAgUk9PVA%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdplex:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}
xiaopaul@Nas_TT:~$                                                                                            

Well, so bad....

It works!

:star: for @Ole for noticing that one command was executed as root and the other a user which unravelled the problem.

I tried it in PC, still works. So, it should be my Synology's problem..

H:\rclone>rclone lsd gdplex: -vv
2023/01/19 23:03:20 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/19 23:03:20 DEBUG : Creating backend with remote "gdplex:"
2023/01/19 23:03:20 DEBUG : Using config file from "C:\\Users\\xiaop\\AppData\\Roaming\\rclone\\rclone.conf"
2023/01/19 23:03:20 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/19 23:03:20 DEBUG : Saving config "token" in section "gdplex" of the config file
2023/01/19 23:03:20 DEBUG : Keeping previous permissions for config file: -rw-rw-rw-
2023/01/19 23:03:20 DEBUG : gdplex: Saved new token in config file
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/19 23:03:20 DEBUG : 6 go routines active

That was unexpected and perfect you tested on the PC. I have no immediate clue.

I will think about it and return tomorrow. :thinking:

Hi, Ole,

Thank you very much. You are so kind. I will contact Synology to see anything they can help.

Than you very much sincerely.

Paul

Thanks, you are welcome :blush:

I don't think this is related to Synology, nothing points in that direction so far.

Meaning: I cannot immediately pinpoint a specific human or software error, like I could in the previous posts.

I can still see a lot of possibilities how this could happen, just needed a little time decide which to pursue/eliminate first and how to best do it.

This is what we know (proven facts):

  • The Client ID you created in the Google API is functioning correct - verified on the PC.
  • The access token pasted into in authorization flow on the NAS is correct - verified by the first lsd on the NAS
  • The second lsd on the NAS fails when trying to obtain a new access token - seen on the NAS
  • The refresh token and possibly also Client ID and Secret are used to obtain a new access token - my oauth2 knowledge

So it is a possibility that the refresh token and possibly also Client ID and Secret are somehow (invisibly) distorted/corrupted when pasted into your NAS terminal software (probably SSH, Putty or similar). Could be human error or some setting/limitation/error in your terminal software. The next steps will eliminate these possibilities.

First, on your NAS - executed as xiaopaul - please post output:

mv /var/services/homes/xiaopaul/.config/rclone/rclone.conf /var/services/homes/xiaopaul/.config/rclone/rclone.conf.bad

Next, on your PC - please post output:

rclone lsd gdplex: -vv
rclone config show gdplex:
copy "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf" "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf.safe"
rclone lsl  "C:\Users\xiaop\AppData\Roaming\rclone"
rclone sha1sum --download "C:\Users\xiaop\AppData\Roaming\rclone"

Next, somehow copy the two files in C:\Users\xiaop\AppData\Roaming\rclone\ into /var/services/homes/xiaopaul/.config/rclone/ on the NAS. I guess you have a drive letter on your PC that points to a shared folder on your NAS which can be used as transit. Do not copy/paste from an editor another editor, I would like to keep your clipboard and terminal software out of the process.

Next verifying files arriving unchanged on your NAS - executed as xiaopaul - please post output:

ls -l /var/services/homes/xiaopaul/.config/rclone/
rclone lsl /var/services/homes/xiaopaul/.config/rclone/
rclone sha1sum --download /var/services/homes/xiaopaul/.config/rclone/

Finally, the usual test on your NAS - executed as xiaopaul - please post output:

rclone config show gdplex:
rclone lsd gdplex: -vv
# Wait in minimum 1 hour
rclone lsd gdplex: -vv

Crossing my fingers, while having carefully prepared for continued trouble shooting :nerd_face:

Hi, Ole,

Thank you.

I have generated the 2 files On PC & copy to my Nas.

H:\rclone>copy "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf" "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf.safe"
        1 file(s) copied.

H:\rclone>rclone lsl  "C:\Users\xiaop\AppData\Roaming\rclone"
      665 2023-01-21 09:22:09.094620800 rclone.conf
      665 2023-01-21 09:22:09.094620800 rclone.conf.safe

H:\rclone>rclone sha1sum --download "C:\Users\xiaop\AppData\Roaming\rclone"
258e7b3856e9b28bc2a2c110cb6b7e7b28e66d81  rclone.conf
258e7b3856e9b28bc2a2c110cb6b7e7b28e66d81  rclone.conf.safe

H:\rclone>copy "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf" "Z:\temp\"
        1 file(s) copied.

H:\rclone>copy "C:\Users\xiaop\AppData\Roaming\rclone\rclone.conf.safe" "Z:\temp\"
        1 file(s) copied.

H:\rclone>

Then cp to Rclone folder on Nas & verifed.

xiaopaul@Nas_TT:~$ mv /var/services/homes/xiaopaul/.config/rclone/rclone.conf /var/services/homes/xiaopaul/.config/rclone/rclone.conf.bad

xiaopaul@Nas_TT:~$ cp /volume2/Backup/temp/rclone.conf /var/services/homes/xiaopaul/.config/rclone/
xiaopaul@Nas_TT:~$ cp /volume2/Backup/temp/rclone.conf.safe /var/services/homes/xiaopaul/.config/rclone/
xiaopaul@Nas_TT:~$ ls -l /var/services/homes/xiaopaul/.config/rclone/
total 12
-rwxrwxrwx+ 1 xiaopaul users 665 Jan 21 09:33 rclone.conf
-rw-------  1 xiaopaul users 652 Jan 19 21:05 rclone.conf.bad
-rwxrwxrwx+ 1 xiaopaul users 665 Jan 21 09:33 rclone.conf.safe
xiaopaul@Nas_TT:~$ rclone lsl /var/services/homes/xiaopaul/.config/rclone/
      665 2023-01-21 09:33:11.618356602 rclone.conf
      652 2023-01-19 21:05:11.234497685 rclone.conf.bad
      665 2023-01-21 09:33:46.247672630 rclone.conf.safe
xiaopaul@Nas_TT:~$ rclone sha1sum --download /var/services/homes/xiaopaul/.config/rclone/
258e7b3856e9b28bc2a2c110cb6b7e7b28e66d81  rclone.conf.safe
258e7b3856e9b28bc2a2c110cb6b7e7b28e66d81  rclone.conf
7520c8e5aa5e4266f584c3e1c9e8559969dd88f5  rclone.conf.bad
xiaopaul@Nas_TT:~$

Executed on Nas.

xiaopaul@Nas_TT:~$ rclone config show gdplex:
[gdplex]
type = drive
client_id = ****222318-62eueh1bjtgftjjcoude7g5ahomj4i2t.apps.googleusercontent.com
client_secret = ****PX-_ecDQfrqJbA3sjUFnN8wDQDPrQNr
scope = drive
token = {"access_token":"ya29.a0AX9GBdWPhWLQOEjbzUmMYDYAyeTX-L-B3vx0ZKkha9sW696Syml5ffxDIQVkzQR_XDGpmgAcAhcTKVzoaFIEdtxRaFdN-LvmJrafWvFA9v1nQhLMWWwEoMXPtz45KMIbs66wIJOpR9wR0J0OYDgm1-XYG65HlA7waCgYKAcMSAQASFQHUCsbCl1E4AwFg7z1oFX2TvD-Jaw0167","token_type":"Bearer","refresh_token":"1//0g6xltqv6To96CgYIARAAGBASNwF-L9IrChUXLcbUFs805mpDYmaYeoKDUHTm6ZFxkh315iBF6Sdi8pfbD1mNkOJqK_4zcaKGBVQ","expiry":"2023-01-21T10:22:08.0939479+08:00"}
team_drive = 0AEHoThJRpKAgUk9PVA
root_folder_id =
xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/21 09:38:29 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/21 09:38:29 DEBUG : Creating backend with remote "gdplex:"
2023/01/21 09:38:29 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/21 09:38:30 DEBUG : 4 go routines active

After 1 hour:

xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/21 10:59:40 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/21 10:59:40 DEBUG : Creating backend with remote "gdplex:"
2023/01/21 10:59:40 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
2023/01/21 10:59:40 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/21 10:59:41 DEBUG : Saving config "token" in section "gdplex" of the config file
2023/01/21 10:59:41 DEBUG : Keeping previous permissions for config file: -rwxrwxrwx
2023/01/21 10:59:41 DEBUG : gdplex: Saved new token in config file
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/21 10:59:41 DEBUG : 6 go routines active

Well, it seems good.

I tried it again in 4 hours.

xiaopaul@Nas_TT:~$ rclone lsd gdplex: -vv
2023/01/21 14:01:30 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "lsd" "gdplex:" "-vv"]
2023/01/21 14:01:30 DEBUG : Creating backend with remote "gdplex:"
2023/01/21 14:01:30 DEBUG : Using config file from "/var/services/homes/xiaopaul/.config/rclone/rclone.conf"
2023/01/21 14:01:30 DEBUG : gdplex: Loaded invalid token from config file - ignoring
2023/01/21 14:01:31 DEBUG : Saving config "token" in section "gdplex" of the config file
2023/01/21 14:01:31 DEBUG : Keeping previous permissions for config file: -rwxrwxrwx
2023/01/21 14:01:31 DEBUG : gdplex: Saved new token in config file
          -1 2022-07-17 16:46:39        -1 Paul Ali
          -1 2022-07-17 16:45:35        -1 Paul's Video
          -1 2023-01-10 11:53:17        -1 tmp
          -1 2022-09-14 16:35:39        -1 学习资料
          -1 2022-06-16 23:37:30        -1 豆瓣电影
2023/01/21 14:01:32 DEBUG : 6 go routines active

Hi Xiao,

Looks good!

Let's fix and verify the permissions on rclone.conf:

ls -l /var/services/homes/xiaopaul/.config/rclone/
chmod 600 /var/services/homes/xiaopaul/.config/rclone/rclone.conf*
ls -l /var/services/homes/xiaopaul/.config/rclone/
rclone lsd gdplex: -vv

I guess it was successful, so now you can start your mount and test it however you like.

Please don't modify or delete rclone.conf.bad and rclone.conf.safe, I would like to keep them for a month or so while finding out what happened, and to allow for quick recovery in case you see issues again when mounting.

While your mount is now (hopefully) running smoothly in the background, I have some questions and analysis I would like to do, to better understand why the rclone authorize approach failed in your setup and how to better guide users towards the copy config file approach when this happens.

I think it is worthwhile because I can see that this thread and other similar have many hits, so I guess we have a lot users facing similar issues and search for answers.

I have noted that rclone.conf.bad is 13 bytes smaller than rclone.conf.safe which could indicate lost characters when pasting back the token obtained on the PC, however the info in rclone.conf.bad looks correct so it may also just be insignificant differences in white space.

What version of rclone did you use for rclone authorize? (please post output from rclone version)
Which shell did you use to do the rclone authorize? (CMD, PowerShell, ...)
Which terminal program do you use to SSH into your Synology? (Putty, ssh, ...)

Do you have any ideas why the rclone authorize approach may have failed?
Do you have any ideas to improve the config flow, error messages or documentation?

HI, Ole,

ls -l /var/services/homes/xiaopaul/.config/rclone/
chmod 600 /var/services/homes/xiaopaul/.config/rclone/rclone.conf*
ls -l /var/services/homes/xiaopaul/.config/rclone/
rclone lsd gdplex: -vv

Yes. It is successful.

H:\rclone>rclone version
rclone v1.61.1
- os/version: Microsoft Windows 11 Pro 21H2 (64 bit)
- os/kernel: 10.0.22000.778 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.19.4
- go/linking: static
- go/tags: cmount

CMD

SSH on CMD, Win11

I am sorry I am not good at Rclone. So I don't have any good answer for your questions.
Actually, I think the config flow have been very good, but Google drives always are changing. It is hard for me, the freshman. :slight_smile:

And, Happy Lunar New Year, Ole.

Here is the best forum on earth I met.

1 Like