Last active
August 29, 2015 14:14
-
-
Save sandromello/c8bfd2deecbcc394f472 to your computer and use it in GitHub Desktop.
Request to vericlock API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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