We may need a fresh auth_token so let’s login first. After that we can build our request and send it. We’ll wrap up by decoding the JSON response and pretty printing it.
auth_token = login(api_url, username, password)
req = urllib.request.Request(
url = api_url+'/repositories',
data = None,
header = {"X-ArchivesSpace-Session": auth_token})
response = urllib.request.urlopen(req)
result = json.JSONDecoder().decode(response.read().decode('utf-8'))
print(json.dumps(result, indent=4))