def get_oauth(self):
        '''
        Retrieve OAuth tokens from Lookout API
        - Returns the access_token and the refresh_token
        - If the access token is already stored, returns the
          variables stored locally
        '''
        token_json = {}
        if self.access_token:
            logging.info("The access token has been found locally")
            return self.access_token, self.refresh_token

        logging.info("Could not find an access token, getting one now")
        
        try:
            response = requests.post(self.api_domain + "/oauth/token",
                                    data="grant_type=client_credentials",
                                    headers=self.header(self.api_key))
            try:
                token_json = json.loads(response.text)                
            except (AttributeError, ValueError) as e:
                logging.info("Exception when requesting new access token: " + str(e))
                logging.info("Refreshing access token...")
                self.refresh_oauth()

            if 'access_token' in token_json and 'error' not in token_json:
                logging.info("Storing creds in Azure Vault")
                self.access_token = token_json['access_token']
                self.refresh_token = token_json['refresh_token']
                self.az_kv.set_secret("AccessToken", self.access_token)
                self.az_kv.set_secret("RefreshToken", self.refresh_token)
                self.az_kv.set_secret("IsValid", "YES")
                self.az_kv.set_secret("AuthRetryCounter", 1)
                logging.info("Got authenticated")
                return self.access_token, self.refresh_token
            else: 
                if token_json['error'] and token_json['error'] == 'invalid_client':
                    # Set flag to avoid unwanted retries in case of invalid key/client
                    self.retry_counter = int(self.retry_counter) + 1
                    self.az_kv.set_secret("AuthRetryCounter", self.retry_counter)
                    if int(self.retry_counter) >= 10:
                        self.az_kv.set_secret("IsValid", "NO")
                logging.info("Auth API retry count :  " + str(self.retry_counter))
                logging.info("Error in oauth")
                logging.info(str(token_json))
                return False
                
        except requests.exceptions.ProxyError as e:
            logging.error("Cannot connect to proxy. Remote end closed connection without response")            
        except requests.exceptions.RequestException as e:
            logging.error(e)

        Retrieve OAuth tokens from Lookout API
        - Returns the access_token and the refresh_token
        - If the access token is already stored, returns the
          variables stored locally
        
Solutions/Lookout/Data Connectors/LookoutAPISentinelConnector/mes_request.py