Skip to content

Instantly share code, notes, and snippets.

@dmitric
Last active December 24, 2015 13:38
Show Gist options
  • Save dmitric/6806061 to your computer and use it in GitHub Desktop.
Save dmitric/6806061 to your computer and use it in GitHub Desktop.
Signing AWS requests
def _sign_params(self, params, host, uri="/", action="GET"):
buffer = "%s\n" % action
buffer += "%s\n" % host
buffer += "%s\n" % uri
buffer += '&'.join("%s=%s" % (self._quote(i[0]), self._quote(i[1])) for i in sorted(params.items()))
signature = base64.b64encode(
hmac.new(self.secret_access_key, buffer, hashlib.sha256).digest()
)
return signature
def _quote(self, obj):
return urllib.quote(str(obj), '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment