Google Drive Access Token expires after an hour

What is the problem you are having with rclone?

My existing gdrive mount has stopped working after 6months because the access token expired. I wanted to refresh the token but now the token expires after 1 hour. I followed different methods by publishing the app and then using if for rclone but nothing has worked so far. I looked already into similar threads but I haven't found any solution

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

rclone v1.59.0

  • os/version: debian 10.10 (64 bit)
  • os/kernel: 4.19.0-17-amd64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.18.3
  • 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)

rclone config

Paste command here

The rclone config contents with secrets removed.

Paste config here
Options:
- type: drive
- client_id:
- client_secret: 
- scope: drive
- token: {"access_token":"","token_type":"Bearer","refresh_token":"","expiry":"2022-08-06T16:47:26.9060257+02:00"}
- team_drive:

A log from the command with the -vv flag

Paste  log here

hello and welcome to the forum,

gdrive tokens expire after one hour.

rclone, on the fly, should refresh the token.
even if rclone is in the middle of running a command.

if you do not want to use tokens, use a service account file.

in addition, google has made some major changes to the oauth2 process,
as a result, rclone had to change.
this has been discussed a number of times in the forum, and can be seen at the rclone change log,

and a debug log of the issue would be helpful

Unfortunately, it doesn't refresh after the hour. I always get the error that the token has expired. I will upload a log tomorrow. I tried the service account file method now but I am not sure if I have done it right.

Is any rclone action with Google Drive supposed to refresh the token? I'm running rclone on a headless remote server, so reauthorizing is a bit of a pain. When I run a simple rclone command like rclone ls drive:, I'm not seeing .config/rclone/rclone.conf get updated with a new token expiration time. Should it?

I'm wondering if the one-hour expiration can be avoided with a cron job that runs a command that refreshes a couple of times per hour, without the need for a user to be present.

hello and welcome to the forum,

in that case, no tokens, no reauthorize.
this is how other backends work, such as S3

Rclone should refresh the token when it has expired using the refresh token, even after it has expired. No need to poll it every hour.

If the token is expiring every hour, it is likely your rclone client_id/client_secret app is not properly configured. I forget exactly the problem, but it is something like not putting it into production.

I put the Google app into production and this seems to be working now. Thanks!

1 Like