You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2018/02/26 19:21:42 UTC
[kibble-scanners] 02/03: Updates to JSON API
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble-scanners.git
commit f8595af0cf00747bd6017720dba344cdfee44d28
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Feb 26 20:20:16 2018 +0100
Updates to JSON API
- We want JSON, so specify that
- Sometimes we need a token (like for Travis) instead of basic auth
---
src/plugins/utils/jsonapi.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/plugins/utils/jsonapi.py b/src/plugins/utils/jsonapi.py
index b896c50..5687156 100644
--- a/src/plugins/utils/jsonapi.py
+++ b/src/plugins/utils/jsonapi.py
@@ -24,15 +24,17 @@ import time
import re
import base64
-def get(url, cookie = None, auth = None):
+def get(url, cookie = None, auth = None, token = None):
headers = {
"Content-type": "application/json",
- "Accept": "*/*"
+ "Accept": "application/json"
}
if auth:
xcreds = auth.encode(encoding='ascii', errors='replace')
bauth = base64.encodebytes(xcreds).decode('ascii', errors='replace').replace("\n", '')
headers["Authorization"] = "Basic %s" % bauth
+ if token:
+ headers["Authorization"] = "token %s" % token
if cookie:
headers["Cookie"] = cookie
rv = requests.get(url, headers = headers)
--
To stop receiving notification emails like this one, please contact
humbedooh@apache.org.