Token not refreshing

#1

Hello, I have been using rclone for a long time and it worked very well. Now I have set up rclone on another server to send backups to google drive and it works after I enter fresh token in configuration, but after one hour or so, it show error “Loaded invalid token from config file - ignoring” and I have to regenerate token and enter in configuration again to make it work.

Not sure what I am missing here, here is my rclone.conf file (with hidden data obviously)

thanks for any help in advance, and thanks for great software you provide for free!

#2

That Loaded invalid token from config file - ignoring is a warning I think isn’t it? Does rclone stop at that point? Can you post the error messages please?

It is also worth checking

  • the permissions on the config file - is it owned by the correct user
  • have you run out of disk space?
#3

Hey Nick, thank you for quick response.

I let it run for a while and I see it’s trying to refresh token but getting connection reset.

> 2019/03/20 10:42:43 DEBUG : remote: Loaded invalid token from config file - ignoring
2019/03/20 10:43:24 DEBUG : remote: Token refresh failed try 1/5: Post https://accounts.google.com/o/oauth2/token: read tcp 172.50.1.22:44346->216.58.214.205:443: read: connection reset by peer
2019/03/20 10:43:25 DEBUG : remote: Loaded invalid token from config file - ignoring
2019/03/20 10:44:05 DEBUG : remote: Token refresh failed try 2/5: Post https://accounts.google.com/o/oauth2/token: read tcp 172.50.1.22:44372->216.58.214.205:443: read: connection reset by peer
2019/03/20 10:44:06 DEBUG : remote: Loaded invalid token from config file - ignoring
2019/03/20 10:44:46 DEBUG : remote: Token refresh failed try 3/5: Post https://accounts.google.com/o/oauth2/token: read tcp 172.50.1.22:44374->216.58.214.205:443: read: connection reset by peer
2019/03/20 10:44:47 DEBUG : remote: Loaded invalid token from config file - ignoring
2019/03/20 10:45:32 DEBUG : remote: Token refresh failed try 4/5: Post https://accounts.google.com/o/oauth2/token: read tcp 172.50.1.22:44416->216.58.214.205:443: read: connection reset by peer
2019/03/20 10:45:33 DEBUG : remote: Loaded invalid token from config file - ignoring
#4

That looks like the machine its running on cannot connect out.

What version of rclone are you using?

Is there a firewall running or something along those lines on the machine?

A router in the middle that might be stopping it?

#5

Version “v1.46”

Even if I completely turn off firewall it does not work.

Both servers are using same router, on another server it works.

#6

What’s the operating system?

#7

CentOS 6 1810

#8

ping 216.58.214.205 returns successfully?

#9

PING 216.58.214.205 (216.58.214.205) 56(84) bytes of data.
64 bytes from 216.58.214.205: icmp_seq=1 ttl=57 time=11.3 ms
64 bytes from 216.58.214.205: icmp_seq=2 ttl=57 time=11.4 ms
64 bytes from 216.58.214.205: icmp_seq=3 ttl=57 time=11.4 ms
64 bytes from 216.58.214.205: icmp_seq=4 ttl=57 time=14.0 ms
64 bytes from 216.58.214.205: icmp_seq=5 ttl=57 time=11.2 ms
^C
— 216.58.214.205 ping statistics —
5 packets transmitted, 5 received, 0% packet loss, time 4301ms
rtt min/avg/max/mdev = 11.295/11.906/14.007/1.051 ms

#10

Freaky.

I’d try to re-run rclone config and get a new token that way and validate that works.

Also date / time on the machine is correct?

#11

I use NTP to sync time very often and time is correct.

If I re-run rclone config and get token from my computers browser then enter it in configuration, then it works I can send backup to gdrive. But I would like to get it refresh automatically as I send backups nightly. I mean I can upload backups manually but it’s not a thing, I use rclone to do it automatically for me, but sadly on this server does not work as it should for some reason.

There are last lines of output of sync after I entered token manually:

2019/03/20 12:54:22 INFO :
Transferred: 0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors: 0
Checks: 45 / 45, 100%
Transferred: 0 / 0, -
Elapsed time: 2.1s

2019/03/20 12:54:22 DEBUG : 13 go routines active
2019/03/20 12:54:22 DEBUG : rclone: Version “v1.46” finishing with parameters [“rclone” “-vv” “sync” “/srv/bekapi/mysqldump/” “remote:/bekapi/”]

#12

The token should automatically refresh. If you re-ran the config and the output looks like it is working.

I’m not sure what you mean by ‘entered the token manually’. What steps are you doing?

#13

Doing

curl -X POST https://accounts.google.com/o/oauth2/token

would be a test of pretty much what rclone does

It should do this

$ curl -X POST https://accounts.google.com/o/oauth2/token
{
  "error": "unsupported_grant_type",
  "error_description": "Invalid grant_type: "
}
#14

I run rclone config, and when it asks if I use headless machine I anwser yes, and it provides me link which I open on my computer browser to approve applcation to access, then I copy refresh token from it and paste back into rclone config line. It works few hours after I do that process.

#15

Here is output on that command:

Error 411 (Length Required)!!1 *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}

411. That’s an error.

POST requests require a Content-length header. That’s all we know.

#16

What’s the exact command you are typing in to generate that message? Do you have the full command/output?

felix@gemini:~$ curl -X POST https://accounts.google.com/o/oauth2/token
{
  "error": "unsupported_grant_type",
  "error_description": "Invalid grant_type:

It should just do that.

What’s the reason for the root folder id?

[remote]
client_id = XXXXXXXXXXXXXXXltsv5samb2ig9.apps.googleusercontent.com
client_secret = XXXXXXXXXXXXKsxSFHF
type = drive
scope = drive
chunk_size = 8M
root_folder_id = XXXXXXXXXXXXot2W-0pg4h2QbUtPdzD
token = {"access_token":"XXXXXXXXXX","token_type":"Bearer","refresh_token":"XXXXXXXX","expiry":"2019-03-19T09:13:09.911256871+01:00"}
#17

Here is screenshot : https://snag.gy/AvoG7H.jpg

I think root folder ID does not matter as it didn’t work without it too. I added it later to sync data to specific folder on gdrive.

#18

And you are using CentOS 7 1810 being the latest rev of that? I may try out a docker and see my results.

#19

Here is what my testing on the same OS looks like:

[root@d51aeb99b119 rclone]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@d51aeb99b119 rclone]# cat rclone.conf
[GD]
type = drive
scope = drive
token = {"access_token":"ya29.token","token_type":"Bearer","refresh_token":"1/_2D2DNLPlO-token","expiry":"2019-03-20T21:04:15.1204168Z"}

and I ran a few commands and seems to be working ok.

[root@d51aeb99b119 rclone]# rclone lsd GD:
          -1 2018-06-07 14:05:06        -1 Arq Backup Data
          -1 2019-02-28 14:42:12        -1 backup
          -1 2017-06-09 13:59:43        -1 media

I also get the same curl output so an option is different.

curl -X POST https://accounts.google.com/o/oauth2/token
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 411 (Length Required)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>411.</b> <ins>That’s an error.</ins>
  <p>POST requests require a <code>Content-length</code> header.  <ins>That’s all we know.</ins>
#20

I made mistake, I dont use CentOS 6 1810, but CentOS release 6.10 (Final)

Also tried command as yours:

➜ ~ rclone -vv lsd remote:
2019/03/20 21:13:09 DEBUG : rclone: Version “v1.46” starting with parameters [“rclone” “-vv” “lsd” “remote:”]
2019/03/20 21:13:09 DEBUG : Using config file from “/root/.config/rclone/rclone.conf”
2019/03/20 21:13:09 DEBUG : remote: Loaded invalid token from config file - ignoring
2019/03/20 21:13:49 DEBUG : remote: Token refresh failed try 1/5: Post https://accounts.google.com/o/oauth2/token: read tcp 172.50.1.22:37300->216.58.214.205:443: read: connection reset by peer