def _do_request(self, method, endpoint, data=None):
        """Perform one request, possibly solving unauthorized return code
        """
        # No token - authorize
        if self.token is None:
            self._do_authorize()

        r = requests.request(
            method,
            "{0}{1}".format(self.base_url, endpoint),
            headers={
                "Authorization": "Bearer {0}".format(self.token),
                "Content-Type": "application/json"
            },
            json=data,
            verify=self.verify_certificate,
            timeout=self.timeout
        )

        if r.status_code == 401:
            self._do_authorize()
            r = requests.request(
                method,
                "{0}{1}".format(self.base_url, endpoint),
                headers={
                    "Authorization": "Bearer {0}".format(self.token),
                    "Content-Type": "application/json"
                },
                json=data,
                verify=self.verify_certificate,
                timeout=self.timeout
            )

        return r
def _do_request ( self , method , endpoint , data = None ) : if self . token is None : self . _do_authorize ( ) r = requests . request ( method , "{0}{1}" . format ( self . base_url , endpoint ) , headers = { "Authorization" : "Bearer {0}" . format ( self . token ) , "Content-Type" : "application/json" } , json = data , verify = self . verify_certificate , timeout = self . timeout ) if r . status_code == 401 : self . _do_authorize ( ) r = requests . request ( method , "{0}{1}" . format ( self . base_url , endpoint ) , headers = { "Authorization" : "Bearer {0}" . format ( self . token ) , "Content-Type" : "application/json" } , json = data , verify = self . verify_certificate , timeout = self . timeout ) return r
Perform one request, possibly solving unauthorized return code