<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _do_authorize(self):
 """ Perform the authorization """

        if self.auth_data is None:
            raise ApiwatcherClientException("You must provide authorization data.")

        r = requests.post(
            "{0}/api/token".format(self.base_url), json=self.auth_data,
            verify=self.verify_certificate, timeout=self.timeout
        )

        if r.status_code == 401:
            raise ApiwatcherClientException("Wrong credentials supplied: {0}".format(
                r.json()["message"]
            ))
        elif r.status_code != 201:
            try:
                reason = r.json()["message"]
            except:
                reason = r.text
            raise ApiwatcherClientException(
                "Authorization failed. Reason {0} {1}".format(
                    r.status_code, reason)
                )
        else:
            data = r.json()["data"]
            self.token = data["access_token"]

            if "refresh_token" in data:
                self.auth_data = {
                    "grant_type": "refresh_token",
                    "refresh_token": data["refresh_token"],
                    "client_id": self.auth_data["client_id"]
                }