RClone's GDrive token reconnect failing

What is the problem you are having with rclone?

(Across three Debian-based distros - 2x Ubuntu 20.04, 1x Proxmox 6.4.) Google Drive tokens appear to last 2-3 weeks. After which, it seems necessary to run rclone config reconnect <Mount>:. This properly dumps a link that I can access and login to, yielding the token, as expected. However, after pasting the token, I receive the following, without fail, across each system (no changes to firewall, DNS, or the like).

Fatal error: failed to get token: Post "https://oauth2.googleapis.com/token": dial tcp: lookup oauth2.googleapis.com on [::1]:53: read udp [::1]:34775->[::1]:53: i/o timeout

(Maybe helpful background – I generated my config using rclone config.)

What is your rclone version (output from rclone version)

$ rclone version
rclone v1.56.1
- os/version: ubuntu 20.04 (64 bit)
- os/kernel: 5.4.0-88-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.16.8
- 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 clone config reconnect Media:
Already have a token - refresh?
y) Yes (default)
n) No
y/n>
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

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

Go to this URL, authenticate then paste the code here.

# Auth URL (this works without fail).

Enter a string value. Press Enter for the default ("").
config_verification_code> # Token retrieved from Google Drive
2021/10/13 02:51:57 NOTICE: Make sure your Redirect URL is set to "urn:ietf:wg:oauth:2.0:oob" in your custom config.
Error: failed to get token: Post "https://oauth2.googleapis.com/token": dial tcp: lookup oauth2.googleapis.com on [::1]:53: read udp [::1]:34775->[::1]:53: i/o timeout

The rclone config contents with secrets removed.

[Media]
type = drive
client_id = ... # Generated from the steps on how to create a Client ID (this works)
client_secret = ... # Generated from the steps on how to create a Client ID (this works)
scope = drive
root_folder_id = ... # Filled in with the ID from the URL, as advised
use_trash = true
skip_gdocs = true
chunk_size = 64M
keep_revision_forever = true
pacer_min_sleep = 10ms
pacer_burst = 200
token = ...
team_drive =

A log from the command with the -vv flag

$ rclone config reconnect Media: -vv
2021/10/13 03:09:15 DEBUG : Setting --config "/labs/media/rclone.conf" from environment variable RCLONE_CONFIG="/labs/media/rclone.conf"
2021/10/13 03:09:15 DEBUG : rclone: Version "v1.56.1" starting with parameters ["rclone" "config" "reconnect" "Media:" "-vv"]
2021/10/13 03:09:15 DEBUG : Using config file from "/labs/media/rclone.conf"
2021/10/13 03:09:15 DEBUG : Media: config in: state="", result=""
2021/10/13 03:09:15 DEBUG : Media: config out: out=&{State:*oauth,teamdrive,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/10/13 03:09:15 DEBUG : Media: config in: state="*oauth,teamdrive,,", result=""
2021/10/13 03:09:15 DEBUG : Media: config out: out=&{State:*oauth-confirm,teamdrive,, Option:true OAuth:<nil> Error: Result:}, err=<nil>
2021/10/13 03:09:15 DEBUG : Media: config: reading config parameter "config_refresh_token"
Already have a token - refresh?
y) Yes (default)
n) No
y/n>
2021/10/13 03:09:34 DEBUG : Media: config in: state="*oauth-confirm,teamdrive,,", result="true"
2021/10/13 03:09:34 DEBUG : Media: config out: out=&{State:*oauth-islocal,teamdrive,, Option:true OAuth:<nil> Error: Result:}, err=<nil>
2021/10/13 03:09:34 DEBUG : Media: config: reading config parameter "config_is_local"
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

y) Yes (default)
n) No
y/n> n
2021/10/13 03:09:38 DEBUG : Media: config in: state="*oauth-islocal,teamdrive,,", result="false"
2021/10/13 03:09:38 DEBUG : Media: config out: out=&{State:*oauth-remote,teamdrive,, Option:<nil> OAuth:<nil> Error: Result:}, err=<nil>
2021/10/13 03:09:38 DEBUG : Media: config in: state="*oauth-remote,teamdrive,,", result=""
2021/10/13 03:09:38 DEBUG : Media: config out: out=&{State:*oauth-do,teamdrive,, Option: OAuth:<nil> Error: Result:}, err=<nil>
2021/10/13 03:09:38 DEBUG : Media: config: reading config parameter "config_verification_code"
Verification code

Go to this URL, authenticate then paste the code here.

# Auth URL (this works without fail).

Enter a string value. Press Enter for the default ("").
config_verification_code> # Token retrieved from Google Drive
2021/10/13 03:09:54 DEBUG : Media: config in: state="*oauth-do,teamdrive,,", result="<Verification-Code>"
2021/10/13 03:09:54 NOTICE: Make sure your Redirect URL is set to "urn:ietf:wg:oauth:2.0:oob" in your custom config.

Google drive tokens should last indefinitely. If they are only lasting a week or two then it is likely you've got your Google client configured wrong.

This appears to be trying to read a local DNS server over IPv6 running on ::1 - does that make sense to you?

What is in your /etc/resolv.conf?

1 Like

Thanks for the replies! :slightly_smiling_face:

Hmm... so, that's what I figured based on some things I've read (across the forum) that @Animosity022 has said. BUT looking over everything, it seems like I do have things configured correctly?

I know there was mention of "GCP project in testing or production" where testing produces 2-3 week tokens and production produces indefinite ones – but I've yet to find that.

Ah, true. Let me revise my statements above about no different DNS. :sweat_smile: I now have an instance of adguardhome running on this server but looking through the logs, I don't see oauth2.googleapis.com getting blocked. (There are a few firebaselogging-pa.googleapis.com calls getting blocked and some *.gvtN.com getting blocked, but I'm not sure if either are related to GCP/rclone config reconnect.)


So, all told, I think the culprit is an improperly configured Google Client. However, I've repeated the steps on the docs numerous times (about 5 at this point, I think) to no avail. What would be helpful for me to post about that? (Sorry, not too familiar with GCP so I'm not sure what's needed/not. :sweat_smile: Also, if helpful, I'm a GSuite subscriber.)

The error is DNS resolution on your server. If you fix that, it will work.

1 Like

Thanks for the quick reply! (Also, sorry for the ping. I forgot that @'ing you would also ping you. :sweat_smile:)

So, I previously tried that (no dice), but for whatever reason it worked just now. :joy: BUT I still have a question about the "expiry" key in the token.

[Media]
type = drive
client_id = ... # Generated from the steps on how to create a Client ID (this works)
client_secret = ... # Generated from the steps on how to create a Client ID (this works)
scope = drive
root_folder_id = ... # Filled in with the ID from the URL, as advised
use_trash = true
skip_gdocs = true
chunk_size = 64M
keep_revision_forever = true
pacer_min_sleep = 10ms
pacer_burst = 200
token = {"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"2021-10-13T16:28:24.122982154+02:00"}
team_drive =

I don't believe "refresh_token" was present before, but more importantly – "expiry" is set to right when I did this refresh, even though it was previously time + 21 days (or thereabouts – so it was set to expire 21 days after I authorized).

Per the following, it seems like the Google Drive token shouldn't have an "expiry" section? Does this check out or am I jumping to conclusions?

It's correct.

Last indefinitely means it renews not that it won't expire forever.

1 Like

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