From 91aeb28c3a12026de7e86427344dcf0cfa04ff77 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 3 Oct 2020 15:40:33 +0200 Subject: [PATCH] Incorrect use of Authorization header --- media/forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/media/forms.py b/media/forms.py index ff89b61..23a162b 100644 --- a/media/forms.py +++ b/media/forms.py @@ -93,7 +93,9 @@ class MediaAdminForm(ModelForm): def download_data_isbndb(self, isbn): api_url = "https://api2.isbndb.com/book/" + str(isbn) + "?Authorization=" + os.getenv("ISBNDB_KEY") - with urllib.request.urlopen(api_url) as url: + req = urllib.request.Request(api_url) + req.add_header("Authorization", os.getenv("ISBNDB_KEY")) + with urllib.request.urlopen(req) as url: data = json.loads(url.read().decode()) self.cleaned_data["title"] = data["title_long"] self.cleaned_data["published_date"] = data["date_published"][:10]