From ed65aa50e9e4ed671f7a11b6169d78ca74ab9bdb Mon Sep 17 00:00:00 2001 From: jeroenlicht Date: Sun, 1 Sep 2019 17:38:50 +0200 Subject: [PATCH] Added User-Agent in graph.py to prevent server blocking Many websites are configured to block requests with a missing User-Agent For me this was causing an error for FETCH_HTTP_NODE on validating my assertion json url: "Unknown Content-Type (Not image/png or image/svg+xml)" It was solved after adding 'User-Agent': 'Open Badges Validator Core' to the headers on line 40 of verifier/tasks/graph.py --- openbadges/verifier/tasks/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbadges/verifier/tasks/graph.py b/openbadges/verifier/tasks/graph.py index b7abd18..31d125f 100644 --- a/openbadges/verifier/tasks/graph.py +++ b/openbadges/verifier/tasks/graph.py @@ -35,7 +35,7 @@ def fetch_http_node(state, task_meta, **options): session = requests.Session() result = session.get( - url, headers={'Accept': 'application/ld+json, application/json, image/png, image/svg+xml'} + url, headers={'User-Agent': 'Open Badges Validator Core', 'Accept': 'application/ld+json, application/json, image/png, image/svg+xml'} ) try: