Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@param method: http method ('GET' or 'POST')
@type location: string
@return: response type and message
@rtype: tuple of int and string
"""
h = httplib2.Http(disable_ssl_certificate_validation=True)
auth_string = base64.encodestring(settings.DATACITE_USERNAME + ':' + settings.DATACITE_PASSWORD)
response, content = h.request(settings.DATACITE_API_URL + req,
method,
body = body_unicode.encode('utf-8'),
headers={'Content-Type':'text/plain;charset=UTF-8',
'Authorization':'Basic ' + auth_string})
if (response.status > 201):
raise DataciteAPIException(response.status, content.decode('utf-8'))
return response.status, content.decode('utf-8')