Backblaze / B2_Command_Line_Tool

The command-line tool that gives easy access to all of the capabilities of B2 Cloud Storage
Other
542 stars 123 forks source link

b2sdk.exception.InvalidAuthToken: Invalid authorization token. Server said: (bad_auth_token) #930

Closed cmccrorie closed 5 months ago

cmccrorie commented 1 year ago

Hello, I am facing an error with Invalid authorisation token when running the following command:

$ duplicity ~ b2://[keyID]:[application key]@[B2 bucket name] (I am replacing ID, Key, and Bucket name with the relevant credentials)

The Error that I receive is:

Traceback (innermost last):
  File "/usr/bin/duplicity", line 92, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 75, in with_tempdir
    fn()
  File "/usr/lib/python3/dist-packages/duplicity/dup_main.py", line 1555, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib/python3/dist-packages/duplicity/commandline.py", line 1236, in ProcessCommandLine
    backup, local_pathname = set_backend(args[0], args[1])
  File "/usr/lib/python3/dist-packages/duplicity/commandline.py", line 1107, in set_backend
    config.backend = backend.get_backend(bend)
  File "/usr/lib/python3/dist-packages/duplicity/backend.py", line 223, in get_backend
    obj = get_backend_object(url_string)
  File "/usr/lib/python3/dist-packages/duplicity/backend.py", line 209, in get_backend_object
    return factory(pu)
  File "/usr/lib/python3/dist-packages/duplicity/backends/b2backend.py", line 126, in __init__
    self.service.authorize_account(u'production', account_id, account_key)
  File "/usr/lib/python3/dist-packages/logfury/_logfury/trace_call.py", line 86, in wrapper
    return function(*wrapee_args, **wrapee_kwargs)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/api.py", line 219, in authorize_account
    self.session.authorize_account(realm, application_key_id, application_key)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/session.py", line 115, in authorize_account
    response = self.raw_api.authorize_account(realm_url, application_key_id, application_key)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/raw_api.py", line 462, in authorize_account
    return self._post_json(realm_url, 'b2_authorize_account', auth)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/raw_api.py", line 458, in _post_json
    return self.b2_http.post_json_return_json(url, headers, params)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/b2http.py", line 303, in post_json_return_json
    return self.post_content_return_json(
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/b2http.py", line 262, in post_content_return_json
    response = self._translate_and_retry(do_post, try_count, post_params)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/b2http.py", line 507, in _translate_and_retry
    return cls._translate_errors(fcn, post_params)
  File "/home/callum/.local/lib/python3.10/site-packages/b2sdk/b2http.py", line 431, in _translate_errors
    raise interpret_b2_error(
 b2sdk.exception.InvalidAuthToken: Invalid authorization token. Server said:  (bad_auth_token)

I am able to authorise the account when running: ./b2-linux authorize-accout

I am using a normal application key now I was using the master application key and was facing the same error.

I am using this guide: https://www.backblaze.com/docs/cloud-storage-configure-backblaze-b2-with-duplicity-on-linux

I am using Ubuntu 22.04 OS.

cmccrorie commented 1 year ago

I have managed to work around this issue and preform a backup with installing Homebrew for Linux (https://docs.brew.sh/Homebrew-on-Linux) and then using Restic following this guide roughly https://szymonkrajewski.pl/macos-backup-restic/

Please be aware if following the Restic guide above that the paths may be different. When installing with Homebrew you will quite often find the correct path under: /home/linuxbrew/.linuxbrew/Cellar/, For this it was /home/linuxbrew/.linuxbrew/Cellar/restic/0.16.0/bin/restic

jsuchan-reef commented 10 months ago

Hi, thanks for the report.

I am facing an error with Invalid authorisation token when running the following command: $ duplicity (...) I am able to authorise the account when running: ./b2-linux authorize-accout

From this I understand the B2 itself is working for you, and the issue is actually in duplicity's integration of B2 SDK. As such I believe this issue should be reported in their bugtracker rather than here.