Created
May 27, 2014 20:58
-
-
Save almet/3151ae17bc880620d26f to your computer and use it in GitHub Desktop.
mohawk + requests = <3
This file contains 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
class HawkAuth(AuthBase): | |
def __init__(self, hawk_credentials): | |
self.hawk_credentials = hawk_credentials | |
def __call__(self, r): | |
content_type = r.headers.get('Content-Type', '') | |
sender = mohawk.Sender( | |
self.hawk_credentials, | |
r.url, | |
r.method, | |
content=r.body, | |
content_type=content_type | |
) | |
r.headers['Authorization'] = sender.request_header | |
return r | |
requests.post('http://localhost', auth=HawkAuth(creds)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment