In case someone is looking for a workaround for this issue on the
current stable version of Duplicity, this patch may be helpful. The
b2backend module in 0.7.11 unnecessarily URL-encodes (mangles) several
API parameters, including the authorization header. As a workaround,
B2 publishes a list of "safe characters" that do not require URL
encoding. This seems to be enough to prevent mangling the
Authorization header.

diff -rNau a/usr/lib/python2.7/dist-packages/duplicity/backends/b2backend.py
b/usr/lib/python2.7/dist-packages/duplicity/backends/b2backend.py
--- a/usr/lib/python2.7/dist-packages/duplicity/backends/b2backend.py
 2018-06-30 11:20:55.862227023 -0500
+++ b/usr/lib/python2.7/dist-packages/duplicity/backends/b2backend.py
 2018-06-30 11:22:37.481447882 -0500
@@ -266,7 +266,8 @@
             data = json.dumps(data) if data else None

         encoded_headers = dict(
-            (k, urllib2.quote(v.encode('utf-8')))
+            # Don't encode safe character list from
https://www.backblaze.com/b2/docs/string_encoding.html. Prevents
mangling Authorization header.
+            (k, urllib2.quote(v.encode('utf-8'),"._-/~!$'()*;=:@"))
             for (k, v) in headers.iteritems()
         )

Reply via email to