Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key and hmac auth support #98

Open
vetsin opened this issue Mar 1, 2024 · 0 comments
Open

Add key and hmac auth support #98

vetsin opened this issue Mar 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@vetsin
Copy link
Collaborator

vetsin commented Mar 1, 2024

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 vetsin added the enhancement New feature or request label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant