Invalid auth token error but the token is valid

Đang mở
#1,073 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
authentication, cli

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
638
Fork
138
Merge trung bình
8 giờ 27 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Backblaze/B2_Command_Line_Tool

Tất cả issue của Backblaze/B2_Command_Line_Tool

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.