def add_auth(self, http_request, **kwargs): headers = http_request.headers params = http_request.params params['AWSAccessKeyId'] = self._provider.access_key params['SignatureVersion'] = self.SignatureVersion params['Timestamp'] = txboto.utils.get_ts() qs, signature = self._calc_signature( http_request.params, http_request.method, http_request.auth_path, http_request.host) txboto.log.debug('query_string: %s Signature: %s' % (qs, signature)) if http_request.method == 'POST': headers['Content-Type'] = ('application/x-www-form-urlencoded;' ' charset=UTF-8') http_request.body = '{}&Signature={}'.format( qs, quote_plus(signature)) http_request.headers['Content-Length'] = str(len(http_request.body)) else: http_request.body = '' # if this is a retried request, the qs from the previous try will # already be there, we need to get rid of that and rebuild it http_request.path = http_request.path.split('?')[0] http_request.path = (http_request.path + '?' + qs + '&Signature=' + quote_plus(signature))
def add_auth(self, req, **kwargs): req.params['AWSAccessKeyId'] = self._provider.access_key req.params['SignatureVersion'] = self.SignatureVersion req.params['Timestamp'] = txboto.utils.get_ts() qs, signature = self._calc_signature(req.params, req.method, req.auth_path, req.host) txboto.log.debug('query_string: %s Signature: %s' % (qs, signature)) if req.method == 'POST': req.headers['Content-Length'] = str(len(req.body)) req.headers['Content-Type'] = req.headers.get('Content-Type', 'text/plain') else: req.body = '' # if this is a retried req, the qs from the previous try will # already be there, we need to get rid of that and rebuild it req.path = req.path.split('?')[0] req.path = (req.path + '?' + qs + '&Signature=' + quote_plus(signature))