Why is duplicity throwing this Traceback? Unauthorized: (unauthorized)

Asked by Jesse Fowers on 2019-02-13

Hello friends of Duplicity!

First I here is the problem I am running into and then I will tell you what trouble shooting I have done.

I am attempting to set up duplicity to backup to Backblaze B2 with this command:

[mycomputer@localhost ~]$ duplicity full --encrypt-key ABCABDA --sign-key EFGEFGEF /home/folder/test b2://MyAccountIDNumber:mYApLICAtiONKeYLoNGAsCIIStRinG@bucketname
Traceback (innermost last):

   .....long traceback, I'll put the whole thing below ....

  File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 55, in _translate_errors
    int(error['status']), error['code'], error['message'], post_params
 Unauthorized: (unauthorized)

Here is what I have checked:

> I am running fedora 29
> duplicity 0.7.18.2
> b2 1.3.8
> python 2.7.15
> I installed the b2 command-line tool using pip2 and not pip3, so its installed in the right place (right?)
> I can use the b2 command-line tool by itself to successfully upload a file to that same b2 bucket using that same application key. So that application key has the proper permissions.
> the gpg keys seem to be functioning properly because I can use duplicity to encrypt, backup/recover to/from a local file location.
> I have b2 backup (box checked) enabled in my b2 account
> I am new b2 user, and have never attempted to use it with duplicity before. So this is not a new error on a previously functioning process.

Any help would be greatly appreciated! Thank you for taking the time to answer my question.

Here is the full traceback for those of you who speak that language:

Traceback (innermost last):
  File "/usr/bin/duplicity", line 1560, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1546, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1385, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1135, in ProcessCommandLine
    backup, local_pathname = set_backend(args[0], args[1])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1010, in set_backend
    globals.backend = backend.get_backend(bend)
  File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 223, in get_backend
    obj = get_backend_object(url_string)
  File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 209, in get_backend_object
    return factory(pu)
  File "/usr/lib64/python2.7/site-packages/duplicity/backends/b2backend.py", line 92, in __init__
    self.service.authorize_account('production', account_id, account_key)
  File "/usr/lib/python2.7/site-packages/logfury/v0_1/trace_call.py", line 84, in wrapper
    return function(*wrapee_args, **wrapee_kwargs)
  File "/usr/lib/python2.7/site-packages/b2/api.py", line 126, in authorize_account
    response = self.raw_api.authorize_account(realm_url, account_id_or_key_id, application_key)
  File "/usr/lib/python2.7/site-packages/b2/raw_api.py", line 166, in authorize_account
    return self._post_json(realm_url, 'b2_authorize_account', auth)
  File "/usr/lib/python2.7/site-packages/b2/raw_api.py", line 162, in _post_json
    return self.b2_http.post_json_return_json(url, headers, params)
  File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 302, in post_json_return_json
    return self.post_content_return_json(url, headers, data, try_count, params)
  File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 275, in post_content_return_json
    response = _translate_and_retry(do_post, try_count, post_params)
  File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 119, in _translate_and_retry
    return _translate_errors(fcn, post_params)
  File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 55, in _translate_errors
    int(error['status']), error['code'], error['message'], post_params
 Unauthorized: (unauthorized)

Question information

Language:
English Edit question
Status:
Solved
For:
Duplicity Edit question
Assignee:
No assignee Edit question
Solved by:
edso
Solved:
2019-02-13
Last query:
2019-02-13
Last reply:
2019-02-13
Best edso (ed.so) said : #1

maybe some key confusion like explained here
  https://github.com/duplicati/duplicati/issues/3366
?

..ede/duply.net

On 13.02.2019 03:22, Jesse Fowers wrote:
> New question #678515 on Duplicity:
> https://answers.launchpad.net/duplicity/+question/678515
>
> Hello friends of Duplicity!
>
> First I here is the problem I am running into and then I will tell you what trouble shooting I have done.
>
> I am attempting to set up duplicity to backup to Backblaze B2 with this command:
>
> [mycomputer@localhost ~]$ duplicity full --encrypt-key ABCABDA --sign-key EFGEFGEF /home/folder/test b2://MyAccountIDNumber:mYApLICAtiONKeYLoNGAsCIIStRinG@bucketname
> Traceback (innermost last):
>
> .....long traceback, I'll put the whole thing below ....
>
> File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 55, in _translate_errors
> int(error['status']), error['code'], error['message'], post_params
> Unauthorized: (unauthorized)
>
> Here is what I have checked:
>
>> I am running fedora 29
>> duplicity 0.7.18.2
>> b2 1.3.8
>> python 2.7.15
>> I installed the b2 command-line tool using pip2 and not pip3, so its installed in the right place (right?)
>> I can use the b2 command-line tool by itself to successfully upload a file to that same b2 bucket using that same application key. So that application key has the proper permissions.
>> the gpg keys seem to be functioning properly because I can use duplicity to encrypt, backup/recover to/from a local file location.
>> I have b2 backup (box checked) enabled in my b2 account
>> I am new b2 user, and have never attempted to use it with duplicity before. So this is not a new error on a previously functioning process.
>
> Any help would be greatly appreciated! Thank you for taking the time to answer my question.
>
> Here is the full traceback for those of you who speak that language:
>
> Traceback (innermost last):
> File "/usr/bin/duplicity", line 1560, in <module>
> with_tempdir(main)
> File "/usr/bin/duplicity", line 1546, in with_tempdir
> fn()
> File "/usr/bin/duplicity", line 1385, in main
> action = commandline.ProcessCommandLine(sys.argv[1:])
> File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1135, in ProcessCommandLine
> backup, local_pathname = set_backend(args[0], args[1])
> File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1010, in set_backend
> globals.backend = backend.get_backend(bend)
> File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 223, in get_backend
> obj = get_backend_object(url_string)
> File "/usr/lib64/python2.7/site-packages/duplicity/backend.py", line 209, in get_backend_object
> return factory(pu)
> File "/usr/lib64/python2.7/site-packages/duplicity/backends/b2backend.py", line 92, in __init__
> self.service.authorize_account('production', account_id, account_key)
> File "/usr/lib/python2.7/site-packages/logfury/v0_1/trace_call.py", line 84, in wrapper
> return function(*wrapee_args, **wrapee_kwargs)
> File "/usr/lib/python2.7/site-packages/b2/api.py", line 126, in authorize_account
> response = self.raw_api.authorize_account(realm_url, account_id_or_key_id, application_key)
> File "/usr/lib/python2.7/site-packages/b2/raw_api.py", line 166, in authorize_account
> return self._post_json(realm_url, 'b2_authorize_account', auth)
> File "/usr/lib/python2.7/site-packages/b2/raw_api.py", line 162, in _post_json
> return self.b2_http.post_json_return_json(url, headers, params)
> File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 302, in post_json_return_json
> return self.post_content_return_json(url, headers, data, try_count, params)
> File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 275, in post_content_return_json
> response = _translate_and_retry(do_post, try_count, post_params)
> File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 119, in _translate_and_retry
> return _translate_errors(fcn, post_params)
> File "/usr/lib/python2.7/site-packages/b2/b2http.py", line 55, in _translate_errors
> int(error['status']), error['code'], error['message'], post_params
> Unauthorized: (unauthorized)
>
>
>
>
>
>
>

Jesse Fowers (jessefowers) said : #2

Thanks edso, that solved my question.

Jesse Fowers (jessefowers) said : #3

Just to help anyone that comes across this same problem here is a quote from the link edso supplied:

> The issue is really with B2's vague documentation, but Duplicati would benefit from being more clear. It's `Account ID` + `Master > Application Key` _**or**_ `Application Key ID` + `Application Key`.

This is what solved my problem. I was using Account ID and Application Key but I needed to be using Application ID with its corresponding Application Key.

Thank you kind internet stranger!