Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a 500 error when trying to create a Google Drive config from the GUI running in a Docker container and it doesn’t open auth window #145

Open
imthenachoman opened this issue Mar 20, 2022 · 12 comments

Comments

@imthenachoman
Copy link

What is the problem you are having with rclone?

I am running rclone gui from a Docker container. I can browse configs fine. I am trying to add one for Google Drive and I am getting a 500 error. It creates the config but never finishes the creation process. It should open a new window so I can auth the Google Drive but it never opens that window.

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

/data # rclone version
rclone v1.58.0
- os/version: alpine 3.15.1 (64 bit)
- os/kernel: 5.10.28-Unraid (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.18
- 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)

n/a - using GUI

The rclone config contents with secrets removed.

it is empty

A log from the command with the -vv flag

Error creating config. Error: Request failed with status code 500

Screenshots

Creating a new config:

image

Before clicking Next

image

Error after clicking Next

image

Console error after clicking Next

image

Config was created but never finished -- it didn't open a new window to auth:

image

@redsector72
Copy link

It seems like it's the last build of rclone that is buggy and I suppose even incompatible with the web gui. Try to download a previuos version. It was working fine for me.

@imthenachoman
Copy link
Author

@redsector72 Are you using it in a Docker container?

@imthenachoman
Copy link
Author

@negative0 @ncw Sorry to bug but is this something you can help with?

@imthenachoman
Copy link
Author

imthenachoman commented Apr 6, 2022

If I had to guess, I'd say the issue is here: https://github.com/rclone/rclone/blob/3425726c503f7822508071b113e1cc5492d538e7/lib/oauthutil/oauthutil.go#L637

From https://github.com/skratchdot/open-golang/:

Open a file, directory, or URI using the OS's default application for that object type.

This works fine when you're on the machine rclone is running on. But if you run rclone in a container then open won't do anything to the host machine.

Does this sound right?

So I guess rclone GUI has to intercept the open request and open it on the user's browser.

Looks like

await axiosInstance.post(urls.createConfig, data);
is where a new config is created. So I guess it makes a post request to the webserver url config/create (from
createConfig: "config/create",
).

This, I assume, calls rclone's API: https://rclone.org/rc/#config-create.

Now, I assume that in the call to config/create the data object needs to include the authorization information from Google Drive. But I can't figure out where in the process that is supposed to be handled?

@imthenachoman
Copy link
Author

Looking through https://rclone.org/commands/rclone_config_create/, I think the process would be to call config/create, which will return a question in JSON blob that then has to be answered in another call to config/create.

@imthenachoman
Copy link
Author

@ncw Sorry to call you out but I'm hoping you can help me get some traction? I'm happy to modify the code but I need some guidance on how the GUI works.

I'd love to get the config create process working when running rclone in a Docker container.

@imthenachoman
Copy link
Author

Is there anyone that can help me with this?

@ncw
Copy link
Member

ncw commented Aug 9, 2022

I'd love to get the config create process working when running rclone in a Docker container.

I don't see how it can ever work.

You can't open a webbrowser window outside the container from within the container.

@imthenachoman
Copy link
Author

imthenachoman commented Aug 9, 2022

I don't see how it can ever work.
You can't open a webbrowser window outside the container from within the container.

There would need to be some small logic changes in the code. Right now, from what I can tell, when you config a remote the code opens a URL. There should be an option to create a remote and have it return a JSON. That JSON has the information needed to finish the configuration (like the URL of the page to open). The caller would take that JSON, do what is needed, and make a second call to rclone with return data to finish the config creation.

Then, the GUI would make the call using this new mechanism. It would take the JSON, send to the client (the browser) that would finish the auth, and then return the data back to rclone.

Does that make sense?

I'm happy to see how I can make those tweaks but I have some questions about the rclone base and GUI code that I need to chat about.

@ncw
Copy link
Member

ncw commented Aug 9, 2022

Sorry, I misunderstood what you were trying to do

This problem has been solved in RCX by parsing the output of rclone config as rclone prints the URL that needs to be opened in the JSON response.

However that doesn't work when configuring things over the rc so won't work for the GUI.

So what needs to happen is that rclone returns the URL in the JSON response instead of logging it

2022/08/09 17:45:54 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=upS8NlYieyGev9BohN-hpQ

We got nearly all the way there with RCX in this issue: rclone/rclone#3455

But that last little - "Open this brower window to continue" state has eluded us.

The config state machine for the oauth is here

https://github.com/rclone/rclone/blob/1ad22b8881ceaa6219f0bc1ae67507c74f49bdb2/lib/oauthutil/oauthutil.go#L440

So what I'd suggest is that GUI sets a config key, say config_no_open_browser and we check that here

https://github.com/rclone/rclone/blob/1ad22b8881ceaa6219f0bc1ae67507c74f49bdb2/lib/oauthutil/oauthutil.go#L553

That would probably mean splitting that state config state in half, and getting the first half to start the webserver and return the URL needed (and probably the URL to redirect to) and the second half to stop the webserver.

The redirect URL would need to point at the IP address of the docker container so rclone received the response. I think RCX runs their own webserver to do this. This might be a bit tricky to arrange.

So to sum that up - not easy - but it would be a worthwhile thing to do.

@dalepmay
Copy link

I'd love to get the config create process working when running rclone in a Docker container.

I don't see how it can ever work.

You can't open a webbrowser window outside the container from within the container.

Overseer, running in Docker, opens a browser window to login with Plex.

@imthenachoman
Copy link
Author

This problem has been solved in RCX

What is RCX?

So to sum that up - not easy - but it would be a worthwhile thing to do.

Agreed.

I am not completely following on everything you said, or what is mentioned in that other issue but my thought is the flow would be like this:

  1. issue command to create config passing initial options like remote type, name, etc...
  2. command would provide the remote URL that the user would need to go for auth-ing (like the actual Google Drive URL) and some token
  3. whatever issued the command would relay the URL back and wait for input of the auth token that the remote gives
  4. issue command providing token from Configurator: sort entries in remote type dropdown #2 and auth token from Explorer: store state in the URL #3

Does that make sense or do I have it completely wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants