def cli_example(): configs = read_file_to_dict() reso = RESO( client_id=configs['reso']['client_id'], client_secret=configs['reso']['client_secret'], # Some vendors bypass access_token by passing and supplying a static value access_token=None if 'access_token' not in configs['reso'] else configs['reso']['access_token'], api_auth_url=configs['reso']['api_auth_url'], api_token_url=configs['reso']['api_token_url'], verify_ssl=configs['reso']['verify_ssl'], api_request_url=configs['reso']['api_request_url']) reso.set_logging_level('debug') req_obj = OpenIDAuthentication( redirect_uri=configs['open_id']['redirect_uri'], scope=configs['open_id']['scope'], reso=reso) response = req_obj.authorize(configs['username'], configs['password']) req_obj.auth_code = response if not reso.access_token: # User did not supply access_token (most common case) auth_token = req_obj.request_access_token() reso.access_token = auth_token http_req = HttpRequest(reso=reso, ) http_req.request_to_file( request_url=configs['http_request']['request_path'], filename=configs['http_request']['filename'], request_accept_type=configs['http_request']['accept_type'], output_format=configs['http_request']['output_format'], overwrite=True, indent=4 # Set to None for pretty print not to be applied )
def test_flow(self): """ This function tests all the flow of this SDK. To test it - remove @skip decorator """ try: configs = read_file_to_dict() reso = RESO( client_id=configs['reso']['client_id'], client_secret=configs['reso']['client_secret'], api_auth_url=configs['reso']['api_auth_url'], api_token_url=configs['reso']['api_token_url'], verify_ssl=configs['reso']['verify_ssl'], api_request_url=configs['reso']['api_request_url'] ) reso.set_logging_level('debug') req_obj = OpenIDAuthentication( redirect_uri=configs['open_id']['redirect_uri'], scope=configs['open_id']['scope'], reso=reso ) response = req_obj.authorize(configs['username'], configs['password']) req_obj.auth_code = response auth_token = req_obj.request_access_token() reso.access_token = auth_token http_req = HttpRequest( reso=reso, ) resp = http_req.request( request_url=configs['http_request']['request_path'], request_accept_type=configs['http_request']['accept_type'], ) except KeyError: raise ValueError('Configs file is not filled.') self.assertTrue(resp)