Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active August 29, 2015 14:14
Show Gist options
  • Save sandromello/c8bfd2deecbcc394f472 to your computer and use it in GitHub Desktop.
Save sandromello/c8bfd2deecbcc394f472 to your computer and use it in GitHub Desktop.
Request to vericlock API
import requests, json, sys, hmac, hashlib
auth_uri = 'https://api.vericlock.com/1.0/auth'
public_key = 'mypublickey'
privateKey = 'myprivatekey'
# Convert to binary??
#privateKey = ''.join(format(ord(n),'b') for n in privateKey)
def genSignature(uri, privateKey, body):
hashStr = uri + body
return hmac.new(privateKey, hashStr, hashlib.sha256).hexdigest()
body = {
'user' : '[email protected]',
'password' : 'mypassword'
}
# convert hash/dictionary into json
body = json.dumps(body)
sig = genSignature('/1.0/auth', privateKey, body)
headers = {
'vericlock_api_public_key' : public_key,
'vericlock_domain' : 'inova.vericlock.com',
'vericlock_signature' : sig,
'Content-Type' : 'application/json'
}
# http request library. Here we start the request
resp = requests.post(auth_uri, headers=headers, data=body)
print resp.text
print resp.status_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment