Skip to content

Commit 110ab36

Browse files
committed
added --print-auth-header option
1 parent 77a1c02 commit 110ab36

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internetarchive/cli/ia_configure.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def setup(subparsers):
6767
parser.add_argument("--print-cookies", "-c",
6868
action="store_true",
6969
help="print archive.org logged-in-* cookies")
70+
parser.add_argument("--print-auth-header", "-a",
71+
action="store_true",
72+
help="print an Authorization header with your IA-S3 keys")
7073

7174
parser.set_defaults(func=main)
7275

@@ -75,6 +78,21 @@ def main(args: argparse.Namespace) -> None:
7578
"""
7679
Main entrypoint for 'ia configure'.
7780
"""
81+
if args.print_auth_header:
82+
secret = args.session.config.get("s3", {}).get("secret")
83+
access = args.session.config.get("s3", {}).get("access")
84+
if not secret or not access:
85+
print('hi')
86+
if not access:
87+
print("error: 'access' key not found in config file, try reconfiguring.",
88+
file=sys.stderr)
89+
elif not secret:
90+
print("error: 'secret' key not found in config file, try reconfiguring.",
91+
file=sys.stderr)
92+
sys.exit(1)
93+
print(f"Authorization: LOW {access}:{secret}")
94+
sys.exit()
95+
7896
if args.print_cookies:
7997
user = args.session.config.get("cookies", {}).get("logged-in-user")
8098
sig = args.session.config.get("cookies", {}).get("logged-in-sig")

0 commit comments

Comments
 (0)