--- a
+++ b/osp-auth-example.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+"""
+Example on how to use the Allura API w/ auth
+"""
+
+import hmac, hashlib
+from datetime import datetime
+import urllib
+from urllib2 import urlopen
+from urlparse import urlparse
+
+class Signer(object):
+
+ def __init__(self, secret_key, api_key):
+ self.secret_key = secret_key
+ self.api_key = api_key
+
+ def __call__(self, path, params):
+ if self.api_key is None:
+ return params
+ params.append(('api_key', self.api_key))
+ params.append(('api_timestamp', datetime.utcnow().isoformat()))
+ message = path + '?' + urllib.urlencode(sorted(params))
+ digest = hmac.new(self.secret_key, message, hashlib.sha256).hexdigest()
+ params.append(('api_signature', digest))
+ return params
+
+SECRET_KEY = ''
+API_KEY = ''
+URL = 'https://opensourceprojects.eu/rest/p/pristine/wp1/wp1tickets/'
+
+def main():
+ sign = Signer(SECRET_KEY, API_KEY)
+ queryparams = sign(urlparse(URL).path, [])
+ result = urlopen(URL+'?'+urllib.urlencode(queryparams))
+ print(result.read())
+
+main()