Gui and google drive on a headless device

What is the problem you are having with rclone?

I want to use rclone on a headless raspberry pi and I need to configure it by gui. I tried before rclone config from cmd-line without problems. After removing rclone.conf I tried to repeat this by gui. I set up a public gui, following GUI :
rclone rcd --rc-web-gui --rc-addr :82 --rc-htpasswd /etc/apache2/htpasswd --rc-web-gui-no-open-browser --log-file=./rclone.log
This is running, I get Status: rClone Backend is connected and working as expected on the gui.
Problem: When I try to create new config and select "Google Drive" as provider, I leave blank the first page "Set up Drive". After "Next" the gui tries to open a browser. The setup breaks. This is the log:

2021/12/15 15:07:12 NOTICE: Serving Web GUI
2021/12/15 15:07:12 NOTICE: Serving remote control on http://[::]:82/
2021/12/15 15:07:12 NOTICE: Web GUI is not automatically opening browser. Navigate to http://gui:-TGjdqus33FNYRwBMAGe6w@[::]:82/?login_token=Z3VpOi1UR2pkcXVzMzNGTllSd0JNQUdlNnc%3D to use.
2021/12/15 15:23:03 NOTICE: Web GUI exists. Update skipped.
2021/12/15 15:23:03 NOTICE: Serving Web GUI
2021/12/15 15:23:03 NOTICE: Serving remote control on http://[::]:82/
2021/12/15 15:23:03 NOTICE: Web GUI is not automatically opening browser. Navigate to http://gui:CrD9fETfTikeDY2HOJd_DQ@[::]:82/?login_token=Z3VpOkNyRDlmRVRmVGlrZURZMkhPSmRfRFE%3D to use.
2021/12/15 15:25:21 NOTICE: Web GUI exists. Update skipped.
2021/12/15 15:25:21 NOTICE: Serving Web GUI
2021/12/15 15:25:21 NOTICE: Serving remote control on http://[::]:82/
2021/12/15 15:25:21 NOTICE: Web GUI is not automatically opening browser. Navigate to http://gui:B8bn3PB32VB2GtDUuYCL0A@[::]:82/?login_token=Z3VpOkI4Ym4zUEIzMlZCMkd0RFV1WUNMMEE%3D to use.
2021/12/15 15:27:42 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=BLlGUk9_Zlol2QbEYeDMgw
2021/12/15 15:27:42 NOTICE: Log in and authorize rclone for access
2021/12/15 15:27:42 NOTICE: Waiting for code...

So I would need a link to the google-verification, to get to code to copy/paste like I did on cmd-line but it ends with a frustrating try to open a browser at the pi.

What is your rclone version (output from rclone version)

latest version:
clone v1.57.0

  • os/version: raspbian 11.1
  • os/kernel: 5.10.63-v7l+ (armv7l)
  • os/type: linux
  • os/arch: arm
  • go/version: go1.17.2
  • 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 rcd --rc-web-gui --rc-addr :82 --rc-htpasswd /etc/apache2/htpasswd --rc-web-gui-no-open-browser --log-file=./rclone.log

The rclone config contents with secrets removed.

[GoogleDrive]
type = drive
token =

A log from the command with the -vv flag

sudo rclone rcd --rc-web-gui --rc-addr :82 --rc-htpasswd /etc/apache2/.htpasswd --rc-web-gui-no-open-browser -vv
2021/12/15 15:34:16 DEBUG : rclone: Version "v1.57.0" starting with parameters ["rclone" "rcd" "--rc-web-gui" "--rc-addr" ":82" "--rc-htpasswd" "/etc/apache2/.htpasswd" "--rc-web-gui-no-open-browser" "-vv"]
2021/12/15 15:34:17 DEBUG : Current tag: v2.0.5, Release tag: v2.0.5
2021/12/15 15:34:17 NOTICE: Web GUI exists. Update skipped.
2021/12/15 15:34:17 INFO  : No username specified. Using default username: gui 
2021/12/15 15:34:17 INFO  : No password specified. Using random password: SspIYK6bB-IkFVLIH65aPw 
2021/12/15 15:34:17 NOTICE: Serving Web GUI
2021/12/15 15:34:17 INFO  : Using "/etc/apache2/.htpasswd" as htpasswd storage
2021/12/15 15:34:17 NOTICE: Serving remote control on http://[::]:82/
2021/12/15 15:34:17 DEBUG : login_token "Z3VpOlNzcElZSzZiQi1Ja0ZWTElINjVhUHc="
2021/12/15 15:34:17 NOTICE: Web GUI is not automatically opening browser. Navigate to http://gui:SspIYK6bB-IkFVLIH65aPw@[::]:82/?login_token=Z3VpOlNzcElZSzZiQi1Ja0ZWTElINjVhUHc%3D to use.
2021/12/15 15:34:18 DEBUG : rc: "core/stats": with parameters map[]
2021/12/15 15:34:18 DEBUG : rc: "core/stats": reply map[bytes:0 checks:0 deletedDirs:0 deletes:0 elapsedTime:2.27664945 errors:0 eta:<nil> fatalError:false renames:0 retryError:false speed:0 totalBytes:0 totalChecks:0 totalTransfers:0 transferTime:0 transfers:0]: <nil>
2021/12/15 15:34:21 DEBUG : rc: "core/stats": with parameters map[]
2021/12/15 15:34:21 DEBUG : rc: "core/stats": reply map[bytes:0 checks:0 deletedDirs:0 deletes:0 elapsedTime:4.601012745 errors:0 eta:<nil> fatalError:false renames:0 retryError:false speed:0 totalBytes:0 totalChecks:0 totalTransfers:0 transferTime:0 transfers:0]: <nil>

I can't imagine that would work.

The way the oauth flows work is they launch an item on localhost which you can't do remotely.

Best bet would be to authorize and copy your config over.

I hoped for a flag I have overseen, that does what the commandline-config does: At the question Auto-config: no -> print a link (do not open a browser) and copy-paste.

What's happening is that rclone is launching a process on localhost so you need rclone installed on the machine that would be running the authorization process.

The WebGUI being remote can't do that.

Headless machines requires you to run a rclone authorize.

What's the goal? Are you trying to have people remotely make configs? The configs are usually a set it and forget it.

I contribute to GitHub - outdoorbits/little-backup-box: Software that turns a single-board computer into a versatile and pocketable backup appliance . That is a mobile backup solution using a Raspberry pi 4, mainly for photographers. Cloud-services are not the core-functionality. But it's nice to have...
So the configuration has to be easy and should be possible to do by smartphone by normal users. First tests are just running great, but against NextCloud/webdav. What I wish is to get the google-link from the gui (as I got at the cli), get the code from google, paste it into the gui... just like the cli.
Do you think, that would be a possible feature-request?

You need rclone on the non headless device to make this work as that's how the Google oAuth process works.

There's no feature that can change Google's authentication process.

in some cases, can use a service account, which does not use oauth
https://rclone.org/drive/#service-account-support

Back to previous problem as you have to move the service account file over.

In that case, just do the rclone config and copy that over.

yes, that is true.

just giving the OP options, using a service account, no need to use another computer with a browser for oauth.
easier to scale to multiple accounts and multiple users.

You'd really want to lock down accounts with a novice user base and a service account makes that super hard and if you re-use, you have a pretty large hole.

If you have to copy a file already, just configure and copy the rclone.conf.

More secure in the end too.

well, oauth is a real pain to script.

on s3, using a batch script, easy to create an access key+id and assign detailed permissions/polices to access buckets.
not sure how much harder/different it could be with google service accounts.

and should not be too hard to get that working with OP software as it already uses over 10 .sh batch scripts.
https://github.com/outdoorbits/little-backup-box/tree/main/scripts

I just published the new version. I made rclone.conf editable by tinyfilemanager. If config doesn't work on the headless rpi, users have to install and config rclone on another machine and copy the section into rclone.conf.
Thank you very much!

... but I just do not understand the problem. I did this via ssh on my headless pi:

rclone config

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
Option config_verification_code.
Verification code
Go to this URL, authenticate then paste the code here.

https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=2022641111111.apps.googleusercontent.com&redirect_uri=urn%3Cietd%3Awg%3Aoauth%3A2.0%3Auob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=Z-kSBpy83E06sQYzavQ2oA
Enter a string value. Press Enter for the default ("").
config_verification_code> 4/1AX4XfWgV4jVjanY9Gu2Ph7nOwHR8UVv2KQ-xtFbpnELW9uqbIkUzYbfvAOc

Sorry, the codes are altered :wink:

But it's working easy:

  • Copy the link https://accounts.google.com/o/oauth2/auth?access_type=offline&...
  • Open it on my laptop
  • login & accept access
  • get the verification code
  • copy it into the pi-dialog

So, what if the gui just presents the link and asks the user to give the verification code?

that is how it works. get the code from the machine with web browser and paste it into the headless machine

you can also just do the whole config setup, including the oauth, on the machine with the web browser and then copy the rclone.conf from that machine to the headless machine.

It's not that simple as you need to run rclone authorize and spawn a webserver as you need to have the right URI for authentication.

etexter@seraphite ~ % rclone authorize drive
2021/12/17 17:26:39 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=tzuK-4ndQD3HrJUaVkyhFg
2021/12/17 17:26:39 NOTICE: Log in and authorize rclone for access
2021/12/17 17:26:39 NOTICE: Waiting for code...

You need to the callback URI properly configured to authenticate as that's the URL in the oAuth process. You can't just paste a link.

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