Access token and refresh token are not being refreshed

What is the problem you are having with rclone?

I have developed a service that operates multiple rclone config files. Upon receiving a request, rclone runs check command with box remote. It works fine for one hour, but then access token expires and refresh token does not refresh access token.

I thought running any Rclone command will refresh a token in the given config file.
Is this expected behaviour?

What is your rclone version (output from rclone version)

rclone v1.52.2

  • os/arch: linux/amd64
  • go version: go1.14.4

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Alpine linux latest

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

Box

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Rclone check

A log from the command with the -vv flag (eg output from rclone -vv copy /tmp remote:tmp)

2020/07/20 10:01:12 DEBUG : rclone: Version "v1.52.2" starting with parameters ["rclone" "ls" "box:SyncTest" "-vv" "--config=/configs/domesticus.conf"]

2020/07/20 10:01:12 DEBUG : Using config file from "/configs/domesticus.conf"                                                                                                         
   24363 unnamed.png                            
                                                                                                                                     │
2020/07/20 10:01:13 DEBUG : 5 go routines active
 

hello and welcome to the forum,

cannot call this a bug yet as there are no errors in the log you posted.

can you post a debug log with the error messages?

It should do but...

Box only lets you use each given refresh token once, so you need to make sure every rclone config file has been created individually.

See: Box

After an hour of running the mentioned command, I receive the following logs:

    2020/07/21 08:38:00 DEBUG : rclone: Version "v1.52.2" starting with parameters ["rclone" "ls" "box:SyncTest" "-vv" "--config=anton-test-team.conf"]

    2020/07/21 08:38:00 DEBUG : Using config file from "/configs/anton-test-team.conf"

    2020/07/21 08:38:00 DEBUG : box root 'SyncTest': Token expired but no uploads in progress - doing nothing

    2020/07/21 08:38:00 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:01 DEBUG : box: Token refresh failed try 1/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:02 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:02 DEBUG : box: Token refresh failed try 2/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:03 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:04 DEBUG : box: Token refresh failed try 3/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:05 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:06 DEBUG : box: Token refresh failed try 4/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:07 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:08 DEBUG : box: Token refresh failed try 5/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:09 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:10 DEBUG : box: Token refresh failed try 1/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

    2020/07/21 08:38:11 DEBUG : box: Loaded invalid token from config file - ignoring

    2020/07/21 08:38:11 DEBUG : box: Token refresh failed try 2/5: oauth2: cannot fetch token: 400 Bad Request

    Response: {"error":"invalid_grant","error_description":"Refresh token has expired"}

I am using separate configs, but from time to time rclone fails to update token in a config. I did not receive any error messages or whatsoever. I randomly get invalid refresh token.
It's hard to capture this issue, because it randomly occurs.

I have found a workaround btw. For the same box app I have created a JWT token. Using --box-box-config-file flag I provide this json file and tokens seem to update correctly

That is the problem I was describing above.

Are you running two rclone's simultaneously? The first might refresh its token and invalidate the refresh token in the config file for the second.

Nice one!

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