What is the problem you are having with rclone?
How can I set an X-Access-Token
header on a webdav type remote using the connection string syntax? I can set an authorization header using the bearer_token
parameter but there doesn't seem to be a 'webdav headers' flag. What am I missing?
What is your rclone version (output from rclone version
)
rclone v1.55.0
Which OS you are using and how many bits (eg Windows 7, 64 bit)
os/type: linux
os/arch: amd64
go/version: go1.16.2
go/linking: static
go/tags: cmount
Which cloud storage system are you using? (eg Google Drive)
webdav
The command you were trying to run (eg rclone copy /tmp remote:tmp
)
curl -u rclone:rclonesecret -H "Content-Type: application/json" -X POST -d '{"_async":true,"srcFs":":webdav,headers=\"x-access-token: srctoken\",url=\"http://source-remote/webdav\":/home/somedir","dstFs":":webdav,headers=\"x-access-token: desttoken\",url=\"http://dest-remote/webdav\":/home/destdir"}' http://localhost:5572/sync/copy
A log from the command with the -vv
flag
Result: The x-access-token
headers are not set:
2021/04/21 08:56:41 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2021/04/21 08:57:54 DEBUG : rc: "sync/copy": with parameters map[_async:true dstFs::webdav,headers="x-access-token: desttoken",url="http://dest-remote/webdav":/home/destdir srcFs::webdav,headers="x-access-token: srctoken",url="http://src-remote/webdav":/home/somedir]
2021/04/21 08:57:54 DEBUG : rc: "sync/copy": reply map[jobid:11]: <nil>
2021/04/21 08:57:54 DEBUG : Creating backend with remote ":webdav,headers=\"x-access-token: srctoken\",url=\"http://src-remote/webdav\":/home/somedir"
2021/04/21 08:57:54 DEBUG : :webdav: detected overridden config - adding "{nsyyx}" suffix to name
2021/04/21 08:57:54 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2021/04/21 08:57:54 DEBUG : HTTP REQUEST (req 0xc000521d00)
2021/04/21 08:57:54 DEBUG : PROPFIND /webdav/home/somedir HTTP/1.1
Host: src-remote
User-Agent: rclone/v1.55.0
Depth: 1
Referer: http://src-remote/webdav/
Accept-Encoding: gzip
2021/04/21 08:57:54 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ncw
(Nick Craig-Wood)
April 21, 2021, 9:50am
2
Headers is an global config item, rather than a backend config item.
This means you'd need to set it with a config override like this in your JSON blob
"_config":{"Headers": [{"Key": "X-Potato", "Value": "yes"}]}
rcuser_rb
(redblom)
April 21, 2021, 11:30am
4
I would need config per remote. So that would be something like ?
curl ... -d '{"srcFs":{"type":"webdav","url":"http://src-remote","_path":"/folder2transfer","_config":{"Headers":[{"Key":"X-Access-Token","Value":"srctoken"}]}},"dstFs":{...,"_config":{"Headers":[{"Key":"X-Access-Token","Value":"desttoken"}]}}}'
Where the tokens of both remotes differ. But I see that this (webdav) option does not exist so I guess it's just not possible right?
ncw
(Nick Craig-Wood)
April 22, 2021, 11:23am
5
Hmm.
I don't think that is going to work without a new parameter to the webdav remote.
That would be easy to add though - a straight port of the headers from the http backend would work.
Want to have a go at that? Happy to talk you through it.
rcuser_rb
(redblom)
April 22, 2021, 11:58am
6
Yeah lets do that. I'll be happy to work on that.
ncw
(Nick Craig-Wood)
April 22, 2021, 12:46pm
7
Great!
What you need to do is steal these bits of code from the http backend
}, {
Name: "headers",
Help: `Set HTTP headers for all transactions
Use this to set additional HTTP headers for all transactions
The input format is comma separated list of key,value pairs. Standard
[CSV encoding](https://godoc.org/encoding/csv) may be used.
For example to set a Cookie use 'Cookie,name=value', or '"Cookie","name=value"'.
You can set multiple headers, e.g. '"Cookie","name=value","Authorization","xxx"'.
`,
Default: fs.CommaSepList{},
Advanced: true,
}, {
}},
}
fs.Register(fsi)
}
// Options defines the configuration for this backend
type Options struct {
Endpoint string `config:"url"`
NoSlash bool `config:"no_slash"`
NoHead bool `config:"no_head"`
Headers fs.CommaSepList `config:"headers"`
}
// Fs stores the interface to the remote HTTP files
type Fs struct {
name string
root string
features *fs.Features // optional features
opt Options // options for this backend
ci *fs.ConfigInfo // global config
endpoint *url.URL
And then a bit of code like this in NewFs to add the header(s) to all requests.
for i := 0; i < len(opt.Headers); i += 2 {
key := opt.Headers[i]
value := opt.Headers[i+1]
f.srv.SetHeader(key, value)
}
Hopefully that is enough hints - see this for more general stuff
# Contributing to rclone #
This is a short guide on how to contribute things to rclone.
## Reporting a bug ##
If you've just got a question or aren't sure if you've found a bug
then please use the [rclone forum](https://forum.rclone.org/) instead
of filing an issue.
When filing an issue, please include the following information if
possible as well as a description of the problem. Make sure you test
with the [latest beta of rclone](https://beta.rclone.org/):
* Rclone version (e.g. output from `rclone -V`)
* Which OS you are using and how many bits (e.g. Windows 7, 64 bit)
* The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)
* A log of the command with the `-vv` flag (e.g. output from `rclone -vv copy /tmp remote:tmp`)
* if the log contains secrets then edit the file with a text editor first to obscure them
This file has been truncated. show original
system
(system)
Closed
June 22, 2021, 8:46am
8
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.