requests-hawk
Project description
This project allows you to use the python requests library with the hawk authentication mechanism.
Hawk itself does not provide any mechanism for obtaining or transmitting the set of shared credentials required, but this project proposes the following scheme:
The server gives you a session token, that you’ll need to derive to get the hawk credentials:
Do an HKDF derivation on the given session token. You’ll need to use the following parameters:
key_material = HKDF(hawk_session, “”, ‘identity.mozilla.com/picl/v1/sessionToken’, 32*3)
The key material you’ll get out of the HKDF need to be separated into two parts, the first 32 hex caracters are the hawk id, and the next 32 ones are the hawk key:
credentials = { 'id': keyMaterial[0:32] 'key': keyMaterial[32:64] 'algorithm': 'sha256' }
Great, how can I use it?
First, you’ll need to install it:
pip install requests-hawk
Then, in your project, you can use it like that:
import requests from requests_hawk import HawkAuth hawk_auth = HawkAuth( hawk_session=resp.headers['hawk-session-token'], server_url=self.server_url ) requests.post("/url", auth=hawk_auth)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file requests-hawk-0.0.1.tar.gz
.
File metadata
- Download URL: requests-hawk-0.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21d86745122961bbdeaaf3e27cb3c49444e86d23d1613ab73a63d7cf2b83bb62 |
|
MD5 | 362889f8a45b584f49ecc8ca73f7d147 |
|
BLAKE2b-256 | 30fef70f069bf2552a5e516bf3e4f753c009c06fdf4f65bfdccc596d6ae9ab31 |