Google Drive Token refresh failed

I wouldn't count on it.

I've been having a the same problem with a Google drive. Oddly it's only the drive associated with my account, shared drives seem to be stable.

When I try to access my Google drive after letting it sit idle rclone reports the following errors.

2021/02/16 17:22:11 ERROR : Google drive root '': Statfs failed: failed to get Drive storageQuota: Get "https://www.googleapis.com/drive/v3/about?alt=json&fields=storageQuota&prettyPrint=false": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect MyNHWG:": context canceled
2021/02/16 17:22:16 ERROR : /: Dir.Stat 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%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%27root%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect MyNHWG:": context canceled
2021/02/16 17:22:21 ERROR : /: Dir.Stat 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%29%2CnextPageToken%2CincompleteSearch&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%27root%27+in+parents%29&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect MyNHWG:": context canceled

This will repeat once or twice, several times if I'm trying to jump to a local mount point, or using the "Explorer" in the web gui. Things come back after issuing a rclone reconnect command and going through the refresh process:

> rclone config reconnect MyDrive:/

Oddly all of the shared drives I have connected stay very stable.

Try commenting out client_id and client_secret in the config file to use rclone's default ones. Then do an rclone config reconnect and see if you get the same problem?

This will tell us whether it is a property of your client_id or not.

1 Like

Eventually failed to refresh again with my client_id. I removed as @ncw suggested and will report back how it goes.

1 Like

Token refresh failed again, exact same sequence in log.

Hmm...

Is there anything unusual about your rclone activity? Might you be running multiple rclone's at the same time? Or have you copied the config file many times to other machines?

Since yesterday I happened to catch it just as it repeated the refresh failure and retry 5 times, but then it recovered and was able to refresh the token on the next minute.

I'm not doing anything differently than I have done for years. I use an rclone mount and mergerfs merging with local files into a single source that feeds Plex/Sonarr/Radarr. New files are pushed to Google Drive through a separate "rclone copy" so that I can apply the --bwlimit for uploads.

I did recently move everything from an old Ubuntu machine to a new Unraid machine and did copy over the rclone config. However, that had been running with no trouble for a few months before this issue started occurring.

I'm having the same problem:

Failed to sync: couldn't list directory: Get "<>": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect ID:": oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Bad Request"
}

Updating the token is impossible for me, it is a script that runs local backup of 90 team drives 1x per week, it is difficult to update 90 tokens .....

I contacted google support and they reported that the problem is that the tokens being generated by RClone have very short validity, I believe they are 0auth and now the google API uses 0auht2

Does anyone know how to make the token's validity get longer?

In the message you posted, you can see it uses oauth2 :slight_smile:

Tokens last one hour per Google's API as that's nothing to do with rclone. It doesn't sound like you got a very good response from them about the issue unfortunately as they gave you a run around.

I may be zeroing in on something.

So my mount started showing the token refresh failures in the typical pattern: failure 5 times, wait 1 minute, repeat. While it was still in this failure pattern, I started a manual rclone copy and then the mount log showed that it loaded a fresh token from config file.

Perhaps there is some difference in the code between the mount and copy to refresh the token. In fact I have never had a problem with a copy, only in a mount.

Interesting...

The problem there has to be the "context canceled"... Why is the burning question.

Ah, I think I understand what is happening.

When the backend is created, the context from the rc call is being passed to it. This gets cancelled at the end of the rc request which means that the token refresher thinks its context has been cancelled too and refuses to do anything.

I've attempted to fix this here - can you give it a try?

v1.55.0-beta.5216.e556df071.fix-backend-cancel-context on branch fix-backend-cancel-context (uploaded in 15-30 mins)

This bit of code got re-worked in the beta so if that works, I'll backport it to the stable branch and get you to test that as well.

I don't see any linux versions listed.

Sorry, the build failed. I've kicked it off again - hopefully it will work this time!

I've merged this to master now which means it will be in the latest beta in 15-30 mins and released in v1.55

Sorry I never got back to try to verify this fix. I switched my mount/unmount scripts to use the standard rclone mount instead of the rc call and it was working fine, so I left it at that.

1 Like

This error started to occur at the beginning of the year ...

before, the validity of the 0auth2 token was not so short.

Google support says that the problem is with RClone that it should automatically revalidate the token and that they have no way of modifying it because the token is generated by RClone.

And here on the RClone forum they informed me they gave me a run around ....

What error you are talking about?

That's how the tokens work as they refresh automatically by rclone.

Not following as you seem to have hijacked someone else's post? If you want to post a question, we're happy to help.

this error

Failed to sync: couldn't list directory: Get "<>": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect ID:": oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Bad Request"
}

yes, i see this post and reply because i have a similar problem...and you answer me...

Do i have to make a new post?

I'm a nice guy at heart so I try to be helpful.

Yes as all the information needed to help you out is not shared. The help and support template collects all that.