def _api_response(self, method, path, body={}, params={}): """ Signs the request using the oauth2 library. """ str_body = encode_json(body) req = self._get_request(method, path, str_body, extra_params=params) data = req.to_postdata() connection = httplib.HTTPConnection(self.host) if self.host.startswith("localhost") and method == "POST": # Workaround for sending api POST requests to local server. connection.request(method, path, data) else: connection.request(method, path + "?" + data, str_body) return connection.getresponse()
def _api_response(self, method, path, body={}, params={}): ''' Signs the request using the oauth2 library. ''' str_body = encode_json(body) req = self._get_request(method, path, str_body, extra_params=params) data = req.to_postdata() connection = httplib.HTTPConnection(self.host) if self.host.startswith('localhost') and method == 'POST': # Workaround for sending api POST requests to local server. connection.request(method, path, data) else: connection.request(method, path + '?' + data, str_body) return connection.getresponse()
def _api_response(self, method, path, body=None): """ Includes the access token as a header in the request. """ connection = httplib.HTTPConnection(self.host) if body: data = encode_json(body) else: data = None headers = {"X-OpenMinds-Access-Token": self.access_token} if method == "GET": if data: path += "?" + data connection.request(method, path, None, headers) else: connection.request(method, path, data, headers) return connection.getresponse()
def _api_response(self, method, path, body=None): ''' Includes the access token as a header in the request. ''' connection = httplib.HTTPConnection(self.host) if body: data = encode_json(body) else: data = None headers = {'X-OpenMinds-Access-Token': self.access_token} if method == 'GET': if data: path += '?' + data connection.request(method, path, None, headers) else: connection.request(method, path, data, headers) return connection.getresponse()