Skip to content

Instantly share code, notes, and snippets.

@almet
Created May 27, 2014 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save almet/3151ae17bc880620d26f to your computer and use it in GitHub Desktop.
Save almet/3151ae17bc880620d26f to your computer and use it in GitHub Desktop.
mohawk + requests = <3
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