Rclone Token Expiring w/ Dropbox

What is the problem you are having with rclone?

I'm trying to use a "token", wording from the rclone.conf file, that is generated by a custom webapp. I can do this with no problem and then put that into my rclone.conf and it will work great for a little while. Eventually, I get a reply from rclone saying:

root@homecloud001:~# rclone lsd dbtest: -vv
2024/02/20 09:23:40 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "lsd" "dbtest:" "-vv"]
2024/02/20 09:23:40 DEBUG : Creating backend with remote "dbtest:"
2024/02/20 09:23:40 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/20 09:23:40 ERROR : : error listing: expired_access_token/
2024/02/20 09:23:40 DEBUG : 7 go routines active
2024/02/20 09:23:40 INFO  : Dropbox root '': Committing uploads - please wait...
2024/02/20 09:23:40 Failed to lsd with 2 errors: last error was: expired_access_token/

This is what I see when it working, right after I put the token into the rclone.conf file:

root@homecloud001:~# rclone lsd dbtest: -vv
2024/02/20 09:47:35 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "lsd" "dbtest:" "-vv"]
2024/02/20 09:47:35 DEBUG : Creating backend with remote "dbtest:"
2024/02/20 09:47:35 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
          -1 1999-12-31 19:00:00        -1 Apps
          -1 1999-12-31 19:00:00        -1 EPQuizes
          -1 1999-12-31 19:00:00        -1 File requests
          -1 1999-12-31 19:00:00        -1 Original Quality
          -1 1999-12-31 19:00:00        -1 Public
          -1 1999-12-31 19:00:00        -1 Sticky Notes
          -1 1999-12-31 19:00:00        -1 chatbot
2024/02/20 09:47:36 DEBUG : 7 go routines active
2024/02/20 09:47:36 INFO  : Dropbox root '': Committing uploads - please wait...

Here is what my token looks like:

{"access_token":"sl.Bv-_XXX","token_type":"bearer","expires_in":"14400","refresh_token":"XzqyN-MfitsXXX","scope":"account_info.read files.content.read files.content.write files.metadata.read files.metadata.write sharing.read sharing.write","uid":"2XXX","account_id":"dbid:AAA78cXHRlqXXX"}

I did see a few other posts that were talking about a client_id/client_secret issue causing this, but I have checked over and over that these are correct. I even tried to set them as ENV variables to ensure the command is using them. I'm going to try setting up a second app on the dropbox dev portal and see if that works with rclone and try to compare things a bit more. I'm just hoping I'm missing something silly here, as that is usually what it comes down to. :smiley:

Any ideas?

EDIT: In case it is needed, I am using the Code Flow to get the token and am using their offline option to generate a longlived refresh_token. The steps they recommend in the FAQ

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

root@homecloud001:~# rclone version
rclone v1.65.2
- os/version: debian 12.4 (64 bit)
- os/kernel: 6.2.16-3-pve (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.6
- go/linking: static
- go/tags: none

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

Dropbox

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

rclone lsd dbtest: -vv

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

root@homecloud001:~# rclone config redacted
[dbtest]
type = dropbox
client_id = XXX
client_secret = XXX
token = XXX

Not really sure what you are doing but rclone Dropbox token looks like this:

token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2023-06-09T11:21:13.603383+01:00"}

You are using something different:

token = {"access_token":"sl.Bv-_XXX","token_type":"bearer","expires_in":"14400","refresh_token":"XzqyN-MfitsXXX","scope":"account_info.read files.content.read files.content.write files.metadata.read files.metadata.write sharing.read sharing.write","uid":"2XXX","account_id":"dbid:AAA78cXHRlqXXX"}

so maybe it works but it is not format rclone understands for refresh - hence when it expires the game is over.

Interesting idea, I guess I could strip out the rest and calculate the expiry field. Will give it a try. I figured it was some sort of legacy token format rclone was using.

You should not have to manipulate or adjust the token rclone gets.

How do you create your client ID and secret?

I created it via https://www.dropbox.com/developers/apps/create

To be clear here, I am generating the token myself via a webui I made. My hope is to be able to use the generated token WITH rclone to build out a backup plugin to use on servers running unraid.

That being said, manually setting up rclone can be a bit much for some, so I'm going for the simplicity that truenas has, hence the handoff of the token to the rclone.conf file.

Let me know if you need more clarification.

In this case I suggest you have a look at rclone source code and replicate token generation from there. Otherwise not sure how you can expect that rclone will handle your custom tokens.

Well, that is what I'm a bit confused on as the token in question is just a regular OAuth2 token that dropbox is returning, nothing custom. I will take a peek and see when I get home tonight.

Yup, looks like rclone does not just store the token as is, instead it has its own format. I'm gonna test it and give it a try, thanks for the sounding board.
newToken := fmt.Sprintf(`{"access_token":"%s","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}`, oldToken)

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