Repository: Backblaze/B2_Command_Line_Tool

Issue:
Attempting to generate an authorized URL using b2id fails
Running

`b2 file url --with-auth --duration 604800 b2id://[REDACTED]`

Results in a stack trace - Works just fine without specifying --with-auth. 
```
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Scripts\b2.exe\__main__.py", line 4, in <module>
    from b2._internal.b2v4.__main__ import main
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Lib\site-packages\b2\_internal\b2v4\__main__.py", line 13, in <module>
    main()
    ~~~~^^
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Lib\site-packages\b2\_internal\console_tool.py", line 5583, in main
    exit_status = ct.run_command(sys.argv)
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Lib\site-packages\b2\_internal\console_tool.py", line 5456, in run_command
    return command.run(args)
           ~~~~~~~~~~~^^^^^^
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Lib\site-packages\b2\_internal\console_tool.py", line 1082, in run
    return self._run(args)
           ~~~~~~~~~^^^^^^
  File "C:\Users\[REDACTED]\.pyenv\pyenv-win\versions\3.13.1\Lib\site-packages\b2\_internal\console_tool.py", line 2903, in _run
    bucket = self.api.get_bucket_by_name(b2_uri.bucket_name)
```


Discussion:

Patch:
diff --git a/b2/_internal/console_tool.py b/b2/_internal/console_tool.py
index 26471b8..d2430e4 100644
--- a/b2/_internal/console_tool.py
+++ b/b2/_internal/console_tool.py
@@ -2875,7 +2875,8 @@ class FileUrlBase(Command):
 
     If it is private, you can use --with-auth to include an authorization
     token in the URL that allows downloads from the given bucket for files
-    whose names start with the given file name.
+    whose names start with the given file name. NOTE: This param can only be used with
+    filename urls.
 
     The URL will work for the given file, but is not specific to that file.  Files
     with longer names that start with the give file name can also be downloaded
@@ -2900,6 +2901,11 @@ class FileUrlBase(Command):
         b2_uri = self.get_b2_uri_from_arg(args)
         url = self.api.get_download_url_by_uri(b2_uri)
         if args.with_auth:
+            if isinstance(b2_uri, B2FileIdURI):
+                raise CommandError(
+                    '--with-auth param cannot be used with `b2id://` urls. Please, use `b2://bucket/filename` url format instead'
+                )
+
             bucket = self.api.get_bucket_by_name(b2_uri.bucket_name)
             auth_token = bucket.get_download_authorization(
                 file_name_prefix=b2_uri.path, valid_duration_in_seconds=args.duration
diff --git a/changelog.d/+with_auth_b2id_error.fixed.md b/changelog.d/+with_auth_b2id_error.fixed.md
new file mode 100644
index 0000000..6f2c297
--- /dev/null
+++ b/changelog.d/+with_auth_b2id_error.fixed.md
@@ -0,0 +1,1 @@
+Display error message when trying to use `--with-auth` param for `b2id://` urls in the `file url` command.


Test patch:
diff --git a/test/unit/console_tool/test_get_url.py b/test/unit/console_tool/test_get_url.py
index 94dd42b..747f948 100644
--- a/test/unit/console_tool/test_get_url.py
+++ b/test/unit/console_tool/test_get_url.py
@@ -62,3 +62,11 @@ def test_get_url__b2id_uri(b2_cli, uploaded_file, uploaded_file_url_by_id):
         ['file', 'url', f'b2id://{uploaded_file["fileId"]}'],
         expected_stdout=f'{uploaded_file_url_by_id}\n',
     )
+
+
+def test_get_url__b2id_uri__with_auth__error(b2_cli, uploaded_file):
+    b2_cli.run(
+        ['file', 'url', '--with-auth', f'b2id://{uploaded_file["fileId"]}'],
+        expected_stderr='ERROR: --with-auth param cannot be used with `b2id://` urls. Please, use `b2://bucket/filename` url format instead\n',
+        expected_status=1,
+    )