Invalid auth token error but the token is valid

オープン
#1,073 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

The failing path is b2 account authorize in b2/_internal/console_tool.py (the authorize method around line 1366), which calls into b2sdk's authorize_account. First check whether the reporter's command passes an empty key id: they export B2_APPLICATION_KEY_ID but pass $B2_KEY_ID, and the prompt still appears. Reproduce with a valid key pair and the --verbose flag. Done means either a clear fix for the argument handling or a documented explanation of the user error.

索引モデルが issue の本文から書いたものです。

説明

invalid/environmental

I get an invalid auth token error, but that token is valid. It is the master application token.

b2 version is b2 command line tool, version 4.3.1
I am running the tool on WSL, if that makes a difference.

The following works with the master key:

❯ B2_APPLICATION_KEY_ID=42---- B2_APPLICATION_KEY=005a----- b2 bucket get  scraped-hackathon-data
--snipped--

Running the took in verbose mode gives the following output

❯ b2 account authorize --verbose $B2_KEY_ID $B2_APPLICATION_KEY
INFO:b2._internal.console_tool:// ========================================  4.3.1   ======================================== \\
DEBUG:b2._internal.console_tool:platform is Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36
DEBUG:b2._internal.console_tool:Python version is CPython 3.12.9 (main, Feb  6 2025, 22:36:39) [GCC 12.2.0]
DEBUG:b2._internal.console_tool:b2sdk version is 2.7.0
DEBUG:b2._internal.console_tool:locale is ('C', 'UTF-8')
DEBUG:b2._internal.console_tool:filesystem encoding is utf-8
DEBUG:b2._internal.console_tool:default encoding is utf-8
DEBUG:b2._internal.console_tool:flags.utf8_mode is 0
DEBUG:b2sdk._internal.account_info.sqlite_account_info:calling SqliteAccountInfo._get_xdg_config_path(cls=<class 'b2sdk._internal.account_info.sqlite_account_info.SqliteAccountInfo'>)
DEBUG:b2sdk._internal.account_info.sqlite_account_info:SqliteAccountInfo file path to use: /home/lyton/.config/b2/account_info
DEBUG:b2sdk._internal.account_info.upload_url_pool:calling UploadUrlPool()
DEBUG:b2sdk._internal.account_info.upload_url_pool:calling UploadUrlPool()
DEBUG:b2sdk._internal.account_info.upload_url_pool:calling UploadUrlPool()
DEBUG:b2sdk._internal.account_info.upload_url_pool:calling UploadUrlPool()
DEBUG:b2sdk.v2.api:calling B2Session(account_info=<b2sdk._internal.account_info.sqlite_account_info.SqliteAccountInfo object at 0x7fc09dbca1e0>, cache=<b2sdk._internal.cache.AuthInfoCache object at 0x7fc09da80e90>, api_config=<b2sdk._internal.api_config.B2HttpApiConfig object at 0x7fc09da80440>)
DEBUG:b2sdk._internal.api:calling B2Session(account_info=<b2sdk._internal.account_info.sqlite_account_info.SqliteAccountInfo object at 0x7fc09dbca1e0>, cache=<b2sdk._internal.cache.AuthInfoCache object at 0x7fc09da80e90>, api_config=<b2sdk._internal.api_config.B2HttpApiConfig object at 0x7fc09da80440>)
DEBUG:b2sdk.v2.api:calling FileVersionFactory(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>)
DEBUG:b2sdk.v2.bucket:calling FileVersionFactory(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>)
DEBUG:b2sdk._internal.api:calling FileVersionFactory(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>)
DEBUG:b2sdk._internal.api:calling DownloadVersionFactory(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>)
DEBUG:b2sdk.v2.api:calling Services(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>, max_upload_workers=10, max_copy_workers=10, max_download_workers=None, save_to_buffer_size=None, check_download_hash=True, max_download_streams_per_file=None)
DEBUG:b2sdk._internal.api:calling Services(api=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>, max_upload_workers=10, max_copy_workers=10, max_download_workers=None, save_to_buffer_size=None, check_download_hash=True, max_download_streams_per_file=None)
DEBUG:b2sdk._internal.utils.thread_pool:calling LazyThreadPool(max_workers=10, kwargs=<class 'inspect._empty'>)
DEBUG:b2sdk._internal.utils.thread_pool:calling LazyThreadPool(max_workers=10, kwargs=<class 'inspect._empty'>)
DEBUG:b2sdk._internal.utils.thread_pool:calling LazyThreadPool(max_workers=None, kwargs=<class 'inspect._empty'>)
DEBUG:b2sdk._internal.transfer.inbound.download_manager:calling ParallelDownloader(min_part_size=104857600, max_streams=None, kwargs={'min_chunk_size': 8192, 'max_chunk_size': 1048576, 'align_factor': None, 'thread_pool': <b2sdk._internal.utils.thread_pool.LazyThreadPool object at 0x7fc09da812e0>, 'check_hash': True})
DEBUG:b2sdk._internal.transfer.inbound.download_manager:calling AbstractDownloader(thread_pool=<b2sdk._internal.utils.thread_pool.LazyThreadPool object at 0x7fc09da812e0>, force_chunk_size=None, min_chunk_size=8192, max_chunk_size=1048576, align_factor=None, check_hash=True, kwargs=<class 'inspect._empty'>)
INFO:b2._internal.console_tool:starting command [b2._internal.console_tool.AccountAuthorize] (arguments hidden)
Backblaze application key:
INFO:b2._internal.console_tool:Using https://api.backblazeb2.com
DEBUG:b2sdk.v2.api:calling B2Api.authorize_account(self=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>, realm='production') (hidden args: application_key_id, application_key)
DEBUG:b2sdk._internal.api:calling B2Api.authorize_account(self=<b2sdk.v2.api.B2Api object at 0x7fc09da80d70>, realm='production') (hidden args: application_key_id, application_key)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.backblazeb2.com:443
DEBUG:urllib3.connectionpool:https://api.backblazeb2.com:443 "POST /b2api/v2/b2_authorize_account HTTP/11" 401 64
DEBUG:b2sdk._internal.exception:calling interpret_b2_error(status=401, code='bad_auth_token', message='', response_headers={'Server': 'nginx', 'Date': 'Mon, 03 Mar 2025 23:46:45 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '64', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0, no-cache, no-store', 'WWW-Authenticate': 'BASIC realm="authorize_account"', 'Strict-Transport-Security': 'max-age=63072000'}, post_params={})
ERROR:b2._internal.console_tool:ConsoleTool account authorization error
Traceback (most recent call last):
  File "b2/_internal/console_tool.py", line 1366, in authorize
  File "logfury/_logfury/trace_call.py", line 86, in wrapper
  File "b2sdk/v2/api.py", line 54, in authorize_account
  File "logfury/_logfury/trace_call.py", line 86, in wrapper
  File "b2sdk/_internal/api.py", line 223, in authorize_account
  File "b2sdk/_internal/session.py", line 116, in authorize_account
  File "b2sdk/_internal/raw_api.py", line 537, in authorize_account
  File "b2sdk/_internal/raw_api.py", line 528, in _post_json
  File "b2sdk/_internal/b2http.py", line 395, in post_json_return_json
  File "b2sdk/_internal/b2http.py", line 361, in post_content_return_json
  File "b2sdk/_internal/b2http.py", line 314, in request_content_return_json
  File "b2sdk/_internal/b2http.py", line 284, in request
  File "b2sdk/_internal/b2http.py", line 595, in _translate_and_retry
  File "b2sdk/v2/b2http.py", line 22, in _translate_errors
  File "b2sdk/_internal/b2http.py", line 525, in _translate_errors
b2sdk._internal.exception.InvalidAuthToken: Invalid authorization token. Server said:  (bad_auth_token)
ERROR: unable to authorize account: Invalid authorization token. Server said:  (bad_auth_token)
INFO:b2._internal.console_tool:\\ ========================================  exit=1  ======================================== //

Running ❯ b2 account authorize --verbose $B2_KEY_ID $B2_APPLICATION_KEY even asks me for the application key

主要言語
Python
スター
638
フォーク
138
平均マージ
8時間 27分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Backblaze/B2_Command_Line_Tool のほかの issue

Backblaze/B2_Command_Line_Tool の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。