Google Drive won't reconnect after resetting credentials

What is the problem you are having with rclone?

I've have set up a GDrive connection and added it as a service with systemctl (running ubuntu).

This was working until I managed to leak my keys and had to reset the google client id/secret.

I tried re-running rclone edit on the drive, but I'm really not certain whether I selected the correct choices.

[Feedback: the user interface of rclone edit is really not what I would call helpful - if anyone is interested I'm happy to provide additional details].

I've also tried the rclone disconnect command but I get the following error:

rclone config disconnect GDrive:
Error: Google drive root '' doesn't support Disconnect

I've also tried rclone about but it returns nothing:

rclone about GDrive:

The rclone logs are showing:

2022/08/30 10:57:20 ERROR : IO error: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files
?alt=json&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%270AGjmuZJIHKZXUk9PVA%27+in
+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? 
- refresh with "rclone config reconnect GDrive:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "invalid_client",
  "error_description": "Unauthorized"
}
2022/08/30 10:57:24 INFO  : Signal received: terminated
2022/08/30 10:57:24 ERROR : /home/bsutton/gdrive: Failed to unmount: exit status 1: fusermount: failed to unmount /home/bsutton/gdrive: Device or resource busy
2022/08/30 10:57:24 INFO  : Exiting...

The contents of my rclone@.service file are:

cat ~/.config/systemd/user/rclone@.service 
# User service for Rclone mounting
#
# Place in ~/.config/systemd/user/
# File must include the '@' (ex rclone@.service)
# As your normal user, run 
#   systemctl --user daemon-reload
# You can now start/enable each remote by using rclone@<remote>
#   systemctl --user enable rclone@Gdrive
#   systemctl --user start rclone@GDrive

[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config GDrive
Documentation=man:rclone(1)
After=network-online.target
Wants=network-online.target 
AssertPathIsDirectory=/home/bsutton/gdrive

[Service]
Type=notify
ExecStart= \
  /usr/bin/rclone mount \
    --config=%h/.config/rclone/rclone.conf \
    --vfs-cache-mode writes \
    --vfs-cache-max-size 100M \
    --log-level INFO \
    --log-file /tmp/rclone-GDrive.log \
    --umask 022 \
    --allow-other \
    GDrive: /home/bsutton/gdrive
ExecStop=/bin/fusermount -u /home/bsutton/gdrive

[Install]
WantedBy=default.target

I've also tried to delete the drive but that doesn't work.

 rclone delete GDrive
2022/08/30 11:29:56 ERROR : : error listing: directory not found
2022/08/30 11:29:56 ERROR : Attempt 1/3 failed with 2 errors and: directory not found
2022/08/30 11:29:56 ERROR : : error listing: directory not found
2022/08/30 11:29:56 ERROR : Attempt 2/3 failed with 2 errors and: directory not found
2022/08/30 11:29:56 ERROR : : error listing: directory not found
2022/08/30 11:29:56 ERROR : Attempt 3/3 failed with 2 errors and: directory not found
2022/08/30 11:29:56 Failed to delete with 2 errors: last error was: directory not found

rclone delete GDrive:

rclone listremotes
GDrive:

``


#### Run the command 'rclone version' and share the full output of the command.
rclone version
rclone v1.59.1
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 5.15.0-43-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.18.5
- go/linking: static
- go/tags: none




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


#### The command you were trying to run (eg `rclone copy /tmp remote:tmp`)  
The systemd service is now failing to start:

systemctl --user start rclone@GDrive
Assertion failed on job for rclone@GDrive.service.

It was running (and generating the above logs) until I shut it down and tried to restart it.

I've check that rclone isn't running:

ps -A | grep rclone



#### The rclone config contents with secrets removed.  
<!--  You should use 3 backticks to begin and end your paste to make it readable.   -->

cat ~/.config/rclone/rclone.conf
[GDrive]
type = drive
scope = drive
token = {"access_token":"XXXXXXXXXXXXXXXX","token_type":"Bearer","refresh_token":"YYYYYY","expiry":"2022-08-30T12:09:54.38324542+10:00"}
team_drive = ZZZZZ
client_id =
client_secret =
root_folder_id =

I've not tried to manually update these. I though running rclone config would do this?


#### A log from the command with the `-vv` flag  
<!-- You should use 3 backticks to begin and end your paste to make it readable.  Or use a service such as https://pastebin.com or https://gist.github.com/   -->

A log from which command? Do you mean the one that is failing?
If so posted above.

rclone about -vv GDrive:
2022/08/30 11:29:11 DEBUG : rclone: Version "v1.59.1" starting with parameters ["rclone" "about" "-vv" "GDrive:"]
2022/08/30 11:29:11 DEBUG : Creating backend with remote "GDrive:"
2022/08/30 11:29:11 DEBUG : Using config file from "/home/bsutton/.config/rclone/rclone.conf"
2022/08/30 11:29:12 DEBUG : Google drive root '': read info from Shared Drive "Accounts"
2022/08/30 11:29:12 DEBUG : 4 go routines active

I've just tried a couple of more things.

I ran:

rclone config reconnect GDrive:

This looks to have updated the expiry date of the refresh but the client id /secret are still incorrect.

here is your Error ... you need to setup Client ID and Secret Key

start "rclone config" select e for editing then select your drive you want edit and start the routine to enter your Client ID and Secret to fetch a new token. You need to give access again to the drive by the app you setup first time by google developer.

@3N3RGY
So I've just ran gclone config and deleted the old remote and recreated it.

The contents of ~/.config/rclone/rclone.conf now contain the correct client id/secret.

However when I try to start the remote it is still failing:

systemctl --user start rclone@GDrive
Assertion failed on job for rclone@GDrive.service.

The only assert I can see is in the service file:

AssertPathIsDirectory=/home/bsutton/gdrive

Of interest, when I try to access that directory:

ls gdrive 
ls: cannot access 'gdrive': Transport endpoint is not connected

Could this be a problem with fuse getting its knickers in a knot?

mount | grep fuse
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=888)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=888)
GDrive: on /home/bsutton/gdrive type fuse.rclone (rw,nosuid,nodev,relatime,user_id=1000,group_id=888,allow_other)

So I did a umount and gdrive directory is now accessible and the rclone service will no start.

So yeah.

My problem now is that the gdrive directory is empty.
I have the real fear that rclone has just deleted the contents of my drive:

2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/shares: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Suppliers/airwallex: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Suppliers: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Statements: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Rill St: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments: Removing directory
2022/08/30 12:18:27 INFO  : Companies/OnePub IP/Agreements: Removing directory
2022/08/30 12:18:27 INFO  : Companies/OnePub IP: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact/Sales/Templates: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact/Sales: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact: Removing directory
2022/08/30 12:18:27 INFO  : Companies: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/shares: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Suppliers/airwallex: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Suppliers: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Statements: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments/Rill St: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Sutton Realestate Investments: Removing directory
2022/08/30 12:18:27 INFO  : Companies/OnePub IP/Agreements: Removing directory
2022/08/30 12:18:27 INFO  : Companies/OnePub IP: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact/Sales/Templates: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact/Sales: Removing directory
2022/08/30 12:18:27 INFO  : Companies/Noojee Contact: Removing directory
2022/08/30 12:18:27 INFO  : Companies: Removing directory
2022/08/30 12:18:27 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)

Yes it appears to have deleted all of my files an my gdrive bin is empty.

Rclone doesn't delete nor do anything on it's own.

It only runs what was asked. That looks like you deleted a bunch of things from the mount but without debug, it's tough to guess what was run.

I deleted the mount point as part of my effort to recreate the remote.

I don't believe that I ever deleted the contents (as opposed to the mount point that contained them).

My main concerns is why aren't they showing up in my gdrive 'bin'?

GDrive, that points to local storage, not a rclone remote.
need to add a colon character :, like so, GDrive:

fwiw, before trying a complex rclone mount, make sure a simple rclone ls works.

note: be careful, rclone delete GDrive: will delete all the files in google drive,

@asdffdsa thanks for the response and the heads up on the delete command. That is certainly not what I expected it to do.

sure, and that can be seen in the top lines of a debug log.

So just a follow up.

I now realized what I did wrong.

When trying to fix my auth issue, I accidentally changed the gdrive I was attached to mounting it into the same local path.

The new gdrive was an empty one, so rcone then went and deleted the local files which is why I saw the list of deletes in the logs.

So my stuff up, but I feel like the rclone behaviour is problematic.

I don't think it should have allowed me to change the gdrive associated with an existing mount point without a warning.

Perhaps rclone should write the name of the gdrive that the mount point is attached to, into the mount point's directory so that rclone can reliably determine a change of gdrive and warn the user.

This scenario seems to have the possibility of loosing data.

Scenario:
My local mount becomes detached (e.g. my creditials expire).
I make some local changes, not realising the drive is detached.

I then switch the mount point to a different gdrive and rclone goes and deletes my local changes.

If the drive is not functional, you can't make changes to it so your scenario does not apply. The mount working or not working is binary. If it's working, you can change things on it. If it isn't working, your changes won't do anything as you can't access it / doesn't work.

OK, so that is good news.

I still believe that rclone should warn a user if the go to attached a different gdrive to an existing mount.

I'm not sure what that means.

You can't mount on top of an existing mount as that would fail.

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