PySNC icon indicating copy to clipboard operation
PySNC copied to clipboard

Add key and hmac auth support

Open vetsin opened this issue 1 year ago • 1 comments

e.g.

secret = b'it would go here'

request = requests.Request(
    'POST', 
    'https://theinstance.service-now.com/api/now/table/incident',
    json={'short_description':'test'}
)
prepped = request.prepare()
signature = hmac.new(secret, prepped.body, digestmod=hashlib.sha256)
encoded_sig = base64.standard_b64encode(signature.digest()).decode()
prepped.headers['x-sn-hmac-signature-256'] = f"keyId=test_secret,signature={encoded_sig}"
print(prepped.headers)

with requests.Session() as session:
    response = session.send(prepped)
    print(response.status_code)
    print(response.text)

The other is more simply ['x-snc-api-key'] = 'key' or whatnot

vetsin avatar Mar 01 '24 17:03 vetsin

we at @noris-network would also like to see this as we use x-sn-apikey as the default auth scheme for API accounts

egmont1227 avatar Jul 03 '25 12:07 egmont1227