mirror of
				https://gitlab.crans.org/mediatek/med.git
				synced 2025-11-04 13:12:18 +01:00 
			
		
		
		
	Incorrect use of Authorization header
This commit is contained in:
		@@ -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]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user