-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Create a comand for automated remote configuration (esp. for options requiring authorization) #3455
Comments
Yes this is a known weakness of the config system. For autoconfig then rclone normally sets the
This answers Yes to most yes/no questions and is enough to get us through most configuration questions. You can preload answers to these yes/no questions in the config, using the answer in the tag, eg
None of that is very elegant or extensible, so a better system would be great! I'd like it to work via the API and the command line ideally. So onto your idea... To make rclone config work in that way would need some way of persisting the state so far - the config file would seem the obvious choice. The actual things returned should probably be an rclone config option At the moment the Config() callback has the parameters
This should really return an error instead of exiting fatally, and it should return a pointer to an Option for the next question, so something like this
On initial call you'd call it
An API like that could work with the API the command line or interactively. @negative0 have you any thoughts on this? This would make the currently difficult to configure remotes in the web gui (eg onedrive) possible. Assume that we made all the |
I realized that my initial idea was more complicated that necessary. To enable configuration with web or other gui state keeping beyond a rclone process lifetime is not actually required. At least for my use case, it could work just like the current |
Would you want to run it via the API or via the command line? |
Command line is probably harder to consume since it would require a message separation mechanism (delimiter or a length prefix). So I would preferably run it over an rc api. And |
If this was only going to work via the API then we could use a simpler method... However this is a reasonably tricky problem either way... I'll think some more on it! |
I'm currently planning on moving RCX from the command line to the RC interface. One of the blockers is the ability to configure OAuth based remotes using RC. The last time I tried this using I would therefore simplify the feature request to the following changes:
Do you remember what you had in mind? For my use case, that's all I need. |
Indeed! Does rclone's attempt to open a browser window work? If it does or could be made to work, then that would fix the problem for most backends.
This won't quite fulfill all the configuration needs - some remotes have a post-token config step - eg google drive lets you choose a team drive (as you noted in your original post).
If it is only going to work via the API it doesn't need to persist stuff which makes the coding much easier. I think my preference would be to implement something like your original proposal a state based call and response system for the extra config. Though I did just have this idea... We are asking for user interaction via the browser for oauth so rclone could do its post config steps in the browser, so direct with the user? |
Unfortunately no (#3686), RCX currently emulates an interactive user to "solve" this issue.
I also had that idea. Potential downside: no localization. Other than that it should work.
No objections. |
I just read through that thread. Should we put the effort into making it work? Would it solve your problem? I can have a go at hacking in the I don't think the skratchdot/open-golang module is being maintained.
OK
👍 |
No, I tried that (#3686 (comment)). It didn't work because Details, if you really want to go down the rabbit hole.
What would most likely work is if rclone would ask the parent app process to open the browser (like termux, but without an additional xdg-open shim binary). However, at that point we're back where we started since we would need to define an interface for that message flow, i.e. an RC interface. In other words, rclone could do exactly the same as termux: am broadcast --user 0 \
-a android.intent.action.VIEW \
-n $HOST_APP_ID/$BROADCAST_RECEIVER \
-d "$URL" \
> /dev/null But this does not open the browser - it just sends a message to the parent app that the browser should be opened with $URL. Which would have the same effect as RC, just over a different, Android-specific IPC channel. So the answer to this question...
.... is still no. Maybe I should explain why I re-activated this issue now. From my first tests it looks like compiling and using rclone as a shared library on Android massively improves command latency and removes TCP/IP as source of failures. However, in a shared library world, there is no stand-alone rclone process any more, which means no clever workarounds with reading from and writing to rclones' standard input and output pipes. BTW: I just tested this - the web GUI has the same problem when running in docker (i.e. broken OAuth when creating a remote config). RC based config & OAuth would help there as well. |
Very interesting details - thanks!
:-)
That is really useful to know - thanks.
Gotcha.
I think this is broken for two reasons 1) the webserver not opening and 2) rclone's webserver socket not being exported. Are you still happy for rclone's webserver to
Assuming that is the case, let's look at your original proposal again
Rclone would need to
A call back URI would be easy enough - is that easy for you? I guess it gets rid of the However I think polling the API might be more regular - that could then return the success/failure and the next step of config (if any). We could do both easily enough. This needs some thought about how long that webserver stays running for - should it time out?
I think we should target this just at the RC API. This means not having to persist anything to disk and with Rclone changes neededWe need to think about the extra config steps. Here is what we might need to do for rclone.
The The
{
"State": "more_required",
"Result": "previous result",
} This should then return
Note that all rclone's config is done with strings which makes life easy. {
"State": "more_required",
"Error": "",
"Help": "The type of the drive",
"Choices": [
{"Value": "onedrive", "Description": "Onedrive main site" },
{"Value": "sharepoint", "Description": "Sharepoint other site" },
{"Value": "driveid", "Description": "Drive ID or something" },
],
"FreeForm": false
}
I think we can massage each backend into this state. The How does that sound to you? It would be possible to make this work with the command line too if intermediate state is persisted into the config file. |
Sounds good, the only things to add:
With a callback URI, users could automatically be redirected into the app and the app would know when the OAuth attempt is finished. The other ideas (custom text, polling API) would also work, although with a user experience that is not quite as smooth. Not every user understands that they should close the browser tab and return to the app after the OAuth authorization process.
That is one option. Alternatively, the webserver could be stopped over RC. This is what RCX currently does (by killing the rclone process) if a user starts another OAuth config without completing the first one. If there's something a non-go programmer like me can do for this feature just point me in the right direction. |
This is a very large change which turns the post Config function in backends into a state based call and response system so that alternative user interfaces can be added. The existing config logic has been converted, but it is quite complicated and folloup commits will likely be needed to fix it! Follow up commits will add a command line and API based way of using this configuration system.
I have pushed the first draft of a new config system in the branch fix-3455-config-api There are some docs on how it works. I've also converted all the backends to use the new system of config. @buengese I was wondering if you've got the time to check this code out and have a look at it? In particular the config for the Jottacloud backend was extremely complicated and I've only been able to test some of the paths since I don't have access to the other types of jotta backends. If you take a look at the Config function in the jottacloud backend rclone/backend/jottacloud/jottacloud.go Lines 125 to 126 in 68842bd
You can get an idea of the code. Unfortunately I had to inline quite a lot of factored out functions to get them returning the questions to the user in the right place. Any help much appreciated! |
I'll take a look at it later today. I've been meaning to have another look at Jottacloud authentication for a while now. It's been a bit of mess for a while now and can probably be simplified a bit. |
I've added a commit to your branch that fixes the jottacloud legacy config and also done some minor rearrangement. Should probably just be squashed in. All paths I could test are now working. |
I've merged that now thanks @buengese I'm going to try to land this branch soon so we can fix any breakage before the release! |
This is a very large change which turns the post Config function in backends into a state based call and response system so that alternative user interfaces can be added. The existing config logic has been converted, but it is quite complicated and folloup commits will likely be needed to fix it! Follow up commits will add a command line and API based way of using this configuration system.
This adds a mechanism to add external interfaces to rclone using the state based configuration.
I've merged the state of play so far into master so this can get more testing before the release. I suspect this will break stuff so testing appreciated! |
This looks really good, finally managed to test it a bit (over HTTP). Three observations:
|
This bug was caused as part of the config rework
@x0b wrote:
Great!
I've been unable to replicate this with I get the error {'Error': 'No Shared Drives found in your account',
'Option': None,
'Result': '',
'State': ''} But the config is saved. I tried this over http to a persistent Can you replicate the problem with
Onedrive is broken :-) I've fixed that now - will merge to master once the tests have passed.
I updated the docs a bit like this - let me know if there is anything missing. The flag This will look something like (some irrelevant detail removed):
The format of The keys of
If
Note that when using At the end of the non interactive process, rclone will return a result If Note that Here is the config.py demo program Line 47 in f593558
|
This bug was caused as part of the config rework
I've merged the fixes for the above now to master. |
This is a very large change which turns the post Config function in backends into a state based call and response system so that alternative user interfaces can be added. The existing config logic has been converted, but it is quite complicated and folloup commits will likely be needed to fix it! Follow up commits will add a command line and API based way of using this configuration system.
…#3455 This adds a mechanism to add external interfaces to rclone using the state based configuration.
…estions rclone#3455 This also factors the config questions into a state based mechanism so a backend can be configured using the same dialog as rclone config but remotely.
This bug was caused as part of the config rework
What is your current rclone version (output from
rclone version
)?However, the behavior was probably introduced in #2472 /
1.43
What problem are you are trying to solve?
Configuring new remotes without using an (unstructured) interactive config session.
Currently, there is at least one remote type (onedrive) that requires using the interactive config dialog to have a working remote. This remote type requires authentication for some of the required configuration options,
drive_type
anddrive_id
.Side note: rclone is a bit inconsistent here.
rclone config providers
shows these options as"Required": "false"
.Effectively, to automate the setup of this remote type you'd have to parse and special-case for this remote type. This affects all GUI-like wrappers for rclone.
How do you think rclone should be changed to solve that?
Auto-configure if possible. If the user only has one drive type and one drive id in his account, this is easy.
For more complicated cases, there should be a command that similar to interactive config, with each invocation returning the next interactive configuration option in a structured format, preferably json.
Imagined User Flow
The imagined feature works like the current implementation until 4., where the additional required parameters can be queried and set.
rclone config create <name> <type> [options]
rclone config continue <name> [<key> <value>] [flags]
Repeat 4. until all required options are set.
E.g. for onedrive
4.
rclone config continue <name>
<---
rclone config continue <name> "drive_type" "onedrive"
<---
rclone config continue <name> "drive_id" "752034815"
<---
The text was updated successfully, but these errors were encountered: