def sharepoint_bi(): headers = {'accept': 'application/json;odata=verbose'} user = '******' pswrd = 'xxxxxx' url = 'https://teamsites.iff.com/corporate/it/AppDev/BI/_api/web/' r = requests.get(url + "lists/getByTitle('SalesRepComments')/items", auth=HttpNtlmAuth(user, pswrd), headers=headers) select = "$select=SalesRep,Comment" filter = "$filter=Cycle eq '009.2012'" r = requests.get(url + "lists/getByTitle('SalesRepComments')/items?" + select + filter, auth=HttpNtlmAuth(user, pswrd), headers=headers) j = r.json() print(r.status_code) print(r.content)
def build_session(self): session = requests.Session() session.verify = self.server_cert_validation == 'validate' # configure proxies from HTTP/HTTPS_PROXY envvars session.trust_env = True settings = session.merge_environment_settings(url=self.endpoint, proxies={}, stream=None, verify=None, cert=None) # we're only applying proxies from env, other settings are ignored session.proxies = settings['proxies'] if self.auth_method == 'kerberos': if not HAVE_KERBEROS: raise WinRMError( "requested auth method is kerberos, but requests_kerberos is not installed" ) # TODO: do argspec sniffing on extensions to ensure we're not setting bogus kwargs on older versions session.auth = HTTPKerberosAuth( mutual_authentication=REQUIRED, delegate=self.kerberos_delegation, force_preemptive=True, principal=self.username, hostname_override=self.kerberos_hostname_override, sanitize_mutual_error_response=False) elif self.auth_method in ['certificate', 'ssl']: if self.auth_method == 'ssl' and not self.cert_pem and not self.cert_key_pem: # 'ssl' was overloaded for HTTPS with optional certificate auth, # fall back to basic auth if no cert specified session.auth = requests.auth.HTTPBasicAuth( username=self.username, password=self.password) else: session.cert = (self.cert_pem, self.cert_key_pem) session.headers['Authorization'] = \ "http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/https/mutual" elif self.auth_method == 'ntlm': if not HAVE_NTLM: raise WinRMError( "requested auth method is ntlm, but requests_ntlm is not installed" ) session.auth = HttpNtlmAuth(username=self.username, password=self.password) # TODO: ssl is not exactly right here- should really be client_cert elif self.auth_method in ['basic', 'plaintext']: session.auth = requests.auth.HTTPBasicAuth(username=self.username, password=self.password) else: raise WinRMError("unsupported auth method: %s" % self.auth_method) session.headers.update(self.default_headers) return session
def get_session(): user = '******' pwd = '!6@7Ck7!Bl7Gi7C' url = "http://swdcfrezd199/ReportServer" session = requests.Session() session.auth = HttpNtlmAuth(user, pwd) r = session.get(url) return [r.status_code, r.text]
def load(self, file): if file.url is None: return None res = requests.get(file.url, auth=HttpNtlmAuth(self.username, self.password)) if res.status_code != 200: print("acess error") return None return res
def refill(self): # TODO: можно в отдельный класс вынести dialog = QDialog() dialog.setWindowTitle('Auth and refill database') info = QLabel() info.setText( """When you click on OK, you will be cleansing a database of employees, start parsing for the collection of employees and populate the database.""") login = QLineEdit("CP\\") password = QLineEdit() password.setEchoMode(QLineEdit.Password) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(dialog.accept) button_box.rejected.connect(dialog.reject) form_layout = QFormLayout() form_layout.addRow("Login:"******"Password:"******"Info", "Failed to login") print('Не удалось авторизоваться') print('rs.status_code = {}'.format(rs.status_code)) print('rs.headers = {}'.format(rs.headers)) return # TODO: move to db.py # Очищение базы данных for i in db_session.query(Employee): db_session.delete(i) db_session.commit() self.run_filter() self.fill_db(session) self.run_filter()
def exec_dump(facility, cred_1, cred_2): url_string = ('http://SERVERNAME/ReportServer/Pages/ReportViewer.aspx?' '%2fFOLDERNAME%2f' 'REPORTNAME' '&FACILITYPARAMETERNAME={fac_string}' '&rs:format=pdf').format(fac_string=facility) r = requests.get(url_string, auth=HttpNtlmAuth(cred_1, cred_2)) return [facility, __name__, r]
def build_password_manager(self): if self.password_manager: return self.password_manager log.debug(u'Constructing password manager') self.password_manager = HttpNtlmAuth(self.username, self.password) return self.password_manager
def _handle_ntlm_auth_401(self, r, kwargs): self.auth = HttpNtlmAuth(self.username, self.password) try: self.auth.init_per_thread_state() except AttributeError: # If we're not on requests 2.8.0+ this method does not exist and # is not relevant. pass # Check that the attr exists because much older versions of requests # set this attribute lazily. For example: # https://github.com/kennethreitz/requests/blob/33735480f77891754304e7f13e3cdf83aaaa76aa/requests/auth.py#L59 if (hasattr(self.auth, 'num_401_calls') and self.auth.num_401_calls is None): self.auth.num_401_calls = 1 # Digest auth would resend the request by itself. We can take a # shortcut here. return self.auth.response_hook(r, **kwargs)
def send_request(username, password, url, domain): print "Trying user %s\\%s" % (domain, username) try: requests.packages.urllib3.disable_warnings(InsecureRequestWarning) req = requests.get(url, auth = HttpNtlmAuth("%s\\%s" % (domain, username), password), headers = {'User-Agent': 'Microsoft'}, verify=False) if not req.status_code == 401: print "User %s password is %s" % (username, password) except: print sys.exc_info()[0]
def send_request(data): try: headers = {} headers["Content-type"] = "text/xml; charset=utf-8" #sys.stderr.write('data='+str(data)) response=requests.post(url,headers = headers, data= data, auth= HttpNtlmAuth(user,password)) return response except: return None
def _authenticate_session(session: Session) -> Session: """ Authenticate the session using NTLM auth """ password = config.get('BC_FIRE_WEATHER_SECRET') user = config.get('BC_FIRE_WEATHER_USER') LOGGER.info('Authenticating user %s at %s', user, BC_FIRE_WEATHER_BASE_URL) session.get(BC_FIRE_WEATHER_BASE_URL, auth=HttpNtlmAuth('idir\\' + user, password)) return session
def __init__(self, token, config=None, verify=True, retries=5, timeout_interval=1.0): self.verify = verify self.client_application = CLIENT_APPLICATION self.config = config self.errorsNotRetry = [401, 403, 413] # Set the proxy information, if present, from the configuration, # with the following format: # config = { # 'proxies': { # # If using 'urls', assume basic auth or no auth. # 'urls': { # 'http': 'http://*****:*****@1.2.3.4:5678', # 'https': 'http://*****:*****@1.2.3.4:5678', # } # # If using 'ntlm', assume NTLM authentication. # 'username_ntlm': 'domain\\username', # 'password_ntlm': 'password' # } # } # Set the basic proxy settings, if present. self.proxy_urls = None self.ntlm_credentials = None if config and 'proxies' in config: if 'urls' in config['proxies']: self.proxy_urls = self.config['proxies']['urls'] if 'username_ntlm' and 'password_ntlm' in config['proxies']: self.ntlm_credentials = { 'username': self.config['proxies']['username_ntlm'], 'password': self.config['proxies']['password_ntlm'] } # Set the extra arguments to requests (proxy and auth). self.extra_args = {} if self.proxy_urls: self.extra_args['proxies'] = self.proxy_urls if self.ntlm_credentials: self.extra_args['auth'] = HttpNtlmAuth( self.ntlm_credentials['username'], self.ntlm_credentials['password']) if self.config and ("client_application" in self.config): self.client_application += ':' + self.config["client_application"] self.credential = _Credentials(token, self.config, verify, proxy_urls=self.proxy_urls, ntlm_credentials=self.ntlm_credentials) if not isinstance(retries, int): raise TypeError('post retries must be positive integer') self.retries = retries self.timeout_interval = timeout_interval self.result = None self._max_qubit_error_re = re.compile( r".*registers exceed the number of qubits, " r"it can\'t be greater than (\d+).*")
def _set_credentials(self, username, password): if self.auth_method == "ntlm": from requests_ntlm import HttpNtlmAuth self.session.auth = HttpNtlmAuth(username, password) elif self.auth_method == "cert": self.session.cert = (username, password) else: self.session.auth = (username, password)
def create_ntlm_session(self, alias, url, auth, headers={}, cookies=None, timeout=None, proxies=None, verify=False, debug=0, max_retries=3, backoff_factor=0.10, disable_warnings=0): """ Create Session: create a HTTP session to a server ``url`` Base url of the server ``alias`` Robot Framework alias to identify the session ``headers`` Dictionary of default headers ``auth`` ['DOMAIN', 'username', 'password'] for NTLM Authentication ``timeout`` Connection timeout ``proxies`` Dictionary that contains proxy urls for HTTP and HTTPS communication ``verify`` Whether the SSL cert will be verified. A CA_BUNDLE path can also be provided. Defaults to False. ``debug`` Enable http verbosity option more information https://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.set_debuglevel ``max_retries`` The maximum number of retries each connection should attempt. ``backoff_factor`` The pause between for each retry ``disable_warnings`` Disable requests warning useful when you have large number of testcases """ if not HttpNtlmAuth: raise AssertionError('Requests NTLM module not loaded') elif len(auth) != 3: raise AssertionError('Incorrect number of authentication arguments' ' - expected 3, got {}'.format(len(auth))) else: ntlm_auth = HttpNtlmAuth('{}\\{}'.format(auth[0], auth[1]), auth[2]) logger.info('Creating NTLM Session using : alias=%s, url=%s, \ headers=%s, cookies=%s, ntlm_auth=%s, timeout=%s, \ proxies=%s, verify=%s, debug=%s ' % (alias, url, headers, cookies, ntlm_auth, timeout, proxies, verify, debug)) return self._create_session(alias, url, headers, cookies, ntlm_auth, timeout, max_retries, backoff_factor, proxies, verify, debug, disable_warnings)
def __init__(self, fields: List[str], username: str, password: str, date_from: str, date_to: str): super().__init__(fields=fields) self.session = requests.Session() self.session.auth = HttpNtlmAuth(username=username, password=password) # workaround: dateutil.parser.isoparse self.date_from = datetime.datetime.fromisoformat(date_from) self.date_to = datetime.datetime.fromisoformat(date_to)
def configure_session(auth, user, password): session = requests.Session() if auth == 'NTLM': session.auth = HttpNtlmAuth( 'domain\\' + user, password ) # Cornell uses ntlm auth, but this can be ported based on the requests library else: session.auth = (user, password) return session
def _determine_auth_handler(self, r): # Determine the Authenticaiton Handler to use (token, kerberos, NTLM) # First try the Token Authentication self._last_request = requests.head(self._get_token_url(r), verify=self.verify) if self._last_request.status_code == 200: ArcGISPortalTokenAuth._init(self, r) self._instanceof = ArcGISPortalTokenAuth self._auth_info = {"isTokenBasedSecurity": True} return True # If token auth fails, check for "Web-Tier" security lr = self._last_request auths = [] if lr.status_code == 401 and lr.headers.get( "WWW-Authenticate") is not None: auths = lr.headers.get("WWW-Authenticate").split(", ") # Try Kerberos if 'Negotiate' in auths: self._last_request = requests.head(r.url, auth=HTTPKerberosAuth(), verify=self.verify) if self._last_request.status_code == 200: self._instanceof = HTTPKerberosAuth self._auth_info = {"isTokenBasedSecurity": False} HTTPKerberosAuth.__init__(self) return True # Try NTLM if 'Negotiate' in auths or 'NTLM' in auths: self._last_request = requests.head(r.url, auth=HttpNtlmAuth( self.username, self.password), verify=self.verify) if self._last_request.status_code == 200: self._instanceof = HttpNtlmAuth self._auth_info = {"isTokenBasedSecurity": False} HttpNtlmAuth.__init__(self, self.username, self.password) return True return False
def _determine_auth_handler(self, r): # Determine the Authenticaiton Handler to use (token, kerberos, NTLM) # First try the Token Authentication try: ArcGISServerTokenAuth._init(self, r) if self._auth_info.get("isTokenBasedSecurity"): self._instanceof = ArcGISServerTokenAuth return True except TokenAuthenticationError: # catch & throw away exception and try other handlers. pass # If token auth fails, check for "Web-Tier" security lr = self._last_request auths = [] if lr.status_code == 401 and lr.headers.get( "WWW-Authenticate") is not None: auths = lr.headers.get("WWW-Authenticate").split(", ") # Try Kerberos if 'Negotiate' in auths: test_req = requests.head(r.url, auth=HTTPKerberosAuth(), verify=self.verify) if test_req.status_code == 200: self._instanceof = HTTPKerberosAuth self._auth_info = {"isTokenBasedSecurity": False} HTTPKerberosAuth.__init__(self) return True # Try NTLM if 'Negotiate' in auths or 'NTLM' in auths: test_req = requests.head(r.url, auth=HttpNtlmAuth(self.username, self.password), verify=self.verify) if test_req.status_code == 200: self._instanceof = HttpNtlmAuth self._auth_info = {"isTokenBasedSecurity": False} HttpNtlmAuth.__init__(self, self.username, self.password) return True return False
def ModifyDashBoardsLibraryView(root_url): post_url_title = root_url + 'lists/GetByTitle(\'Content Repository\')/Views/getByTitle(\'All Items\')/viewfields/removeviewfield(\'Title\')' post_url_keywords = root_url + 'lists/GetByTitle(\'Content Repository\')/Views/getByTitle(\'All Items\')/viewfields/removeviewfield(\'Keywords\')' post_url_pages_columns_contact = root_url + 'lists/GetByTitle(\'Pages\')/Views/getByTitle(\'All Documents\')/viewfields/removeviewfield(\'PublishingContact\')' post_url_pages_columns_pagelayout = root_url + 'lists/GetByTitle(\'Pages\')/Views/getByTitle(\'All Documents\')/viewfields/removeviewfield(\'PublishingPageLayout\')' headers_delete = { 'X-RequestDigest': token, 'Accept': 'application/json; odata=verbose', 'Content-Type': 'application/json; odata=verbose', 'IF-MATCH': "*", 'X-HTTP-Method': 'DELETE' } time.sleep(2) r2 = requests.post(post_url_title, auth=HttpNtlmAuth(username, password), headers=headers_delete, verify=True, timeout=30) time.sleep(2) r4 = requests.post(post_url_keywords, auth=HttpNtlmAuth(username, password), headers=headers_delete, verify=True, timeout=30) time.sleep(2) r5 = requests.post(post_url_pages_columns_contact, auth=HttpNtlmAuth(username, password), headers=headers_delete, verify=True, timeout=30) time.sleep(2) r6 = requests.post(post_url_pages_columns_pagelayout, auth=HttpNtlmAuth(username, password), headers=headers_delete, verify=True, timeout=30) time.sleep(2) logger.debug("Remove Title from COntent Repository %s", str(r2.status_code)) logger.debug("Remove contact from DataConnection %s", str(r5.status_code)) logger.debug("Remove pagelayout from DataConnection %s", str(r6.status_code))
def download(self) -> list: dl_files = [] # parse url parsed = urlparse(self.site) scheme = 'https' if parsed.scheme == '' else parsed.scheme version = 365 if self.version == '365': sp_version = Version.v365 else: sp_version = Version.v2007 try: if sp_version == Version.v365: authcookie = Office365(f'{scheme}://{parsed.netloc}', username=self.username, password=self.password).GetCookies() else: cred = HttpNtlmAuth(self.username, self.password) except: raise Exception( f'Unable to authenticate using supplied user name and password.' ) else: self.display_info('Sucessfully authnticated') try: if sp_version == Version.v365: site = Site(self.site, version=sp_version, authcookie=authcookie) else: site = Site(self.site, version=sp_version, auth=cred) except: raise Exception(f'{self.site} is not a valid site') else: self.display_info(f'Sucessfully accessed site {self.site}') # build path to document folder doc_path = os.path.join(parsed.path, self.docs) try: folder = site.Folder(doc_path) for f in folder.files: fname = f['Name'] if fnmatch.fnmatch(fname, self.filespec): dest = os.path.join(self.savepath, fname) with open(dest, mode='wb') as file: file.write(folder.get_file(fname)) dl_files.append(dest) except: raise Exception(f'Unable to download files from {self.docs}') return dl_files
def fileDownloader(self, url): #Download files to folder global ignore_ssl extList = url.split('.') extension = extList.pop() fileList = url.split('/') fName = fileList.pop() headers = { 'user-agent': random.choice(agents).strip(), } if 'txt' in extension or 'stp' in extension or 'xlsx' in extension or 'xls' in extension or 'doc' in extension or 'docx' in extension or 'pdf' in extension or 'xml' in extension or 'config' in extension or 'conf' in extension or 'aspx' in extension or 'asp' in extension or 'webpart' in extension or 'csv' in extension: if authed: if cookie is not None: self.resp = requests.get(url, cookies=cookie, stream=True, verify=ignore_ssl, headers=headers, proxies=self.proxy) else: self.resp = requests.get(url, auth=HttpNtlmAuth( username, password), stream=True, verify=ignore_ssl, headers=headers, proxies=self.proxy) else: self.resp = requests.get(url, stream=True, headers=headers, proxies=self.proxy, verify=ignore_ssl) if 'asp' in extension or 'aspx' in extension: if '<%' not in self.resp.text and '%>' not in self.resp.text: #Interpreted asp and aspx must be ignored out = "[+] Downloading: %s" % (fName) self.printer(out, GREEN) with open(fileName + '/' + fName, 'wb') as f: for chunk in self.resp.iter_content(chunk_size=1024): if chunk: # filter out keep-alive new chunks f.write(chunk) f.flush() out = "[+] Downloading: %s" % (fName) self.printer(out, GREEN) with open(fileName + '/' + fName, 'wb') as f: for chunk in self.resp.iter_content(chunk_size=1024): if chunk: # filter out keep-alive new chunks f.write(chunk) f.flush() f.close()
def sendData(self, url, data, headers): global counter, ignore_ssl try: if authed: if cookie is not None: self.resp = requests.post(url, cookies=cookie, data=data, headers=headers, verify=ignore_ssl, proxies=self.proxy) else: self.resp = requests.post(url, auth=HttpNtlmAuth( username, password), data=data, headers=headers, verify=ignore_ssl, proxies=self.proxy) else: self.resp = requests.post(url, data=data, headers=headers, verify=ignore_ssl, proxies=self.proxy) respSize = len(self.resp.text) if self.resp is not None: #if self.resp.status_code == 200: # out = "[+] [%s][%s][%sb] - %s" % (counter, self.resp.status_code, respSize, url.strip()) # self.printer(out, GREEN) # foundURLs.append(url) if self.resp.status_code == 400: out = "[-] [%s][%s][%sb] - %s" % ( counter, self.resp.status_code, respSize, url.strip()) self.printer(out, RED) if self.resp.status_code == 404: out = "[-] [%s][%s][%sb] - %s" % ( counter, self.resp.status_code, respSize, url.strip()) self.printer(out, RED) if self.resp.status_code == 401 or self.resp.status_code == 403: out = "[-] [%s][%s][%sb] - %s" % ( counter, self.resp.status_code, respSize, url.strip()) self.printer(out, BLUE) if self.resp.status_code == 302: out = "[-] [%s][%s][%sb] - %s" % ( counter, self.resp.status_code, respSize, url.strip()) self.printer(out, YELLOW) if self.resp.status_code == 500: out = "[-] [%s][%s][%sb] - %s" % ( counter, self.resp.status_code, respSize, url.strip()) self.printer(out, PURPLE) counter = counter + 1 except Exception, e: print e
def crawler(url): global proxy, ignore_ssl queue = foundURLs[:] #clone foundURLs. queue used for processing URLs and foundURLs used to prevent rescans urlList = url.split('/') baseURL = '/'.join(urlList[:3]) headers = { 'user-agent': random.choice(agents).strip(), } try: while len(queue) > 0: qURL = queue.pop(0) if authed: if cookie is not None: response = requests.get(qURL, cookies=cookie, verify=ignore_ssl, headers=headers, proxies=proxy) else: response = requests.get(qURL, auth=HttpNtlmAuth( username, password), verify=ignore_ssl, headers=headers, proxies=proxy) else: response = requests.get(qURL, verify=ignore_ssl, headers=headers, proxies=proxy) soup = bs4.BeautifulSoup(response.text) for link in soup.find_all('a'): hLink = link.get('href') if hLink is not None: if '/' in hLink: if 'http' in hLink: if qURL in hLink and qURL not in foundURLs and '..' not in hLink: #It's in scope thread = URLThread(hLink) thread.start() thread.join() if thread.resp.status_code == 200: queue.append(hLink) else: if (baseURL + '/' + hLink.strip('/') ) not in foundURLs and '..' not in hLink: thread = URLThread(baseURL + '/' + hLink.strip('/')) thread.start() thread.join() if thread.resp.status_code == 200: queue.append(baseURL + '/' + hLink.strip('/')) except KeyboardInterrupt, e: return
def auth(self): token = self.config.get(Config.DEFAULT_SECTION, 'token', fallback=None) if token: creds = base64.b64decode(token).decode().rstrip() username, password = creds.split(':') else: username, password = common.get_user_credentials() session = requests.Session() try: if self.ntlmauth: form_response = session.get(self.idpurl, verify=self.sslverification, auth=HttpNtlmAuth(username, password)) else: form_response = session.get(self.idpurl, verify=self.sslverification) formsoup = BeautifulSoup(form_response.text, "html.parser") payload_dict = {} for inputtag in formsoup.find_all(re.compile('(INPUT|input)')): name = inputtag.get('name', '') value = inputtag.get('value', '') if "user" in name.lower(): payload_dict[name] = username elif "pass" in name.lower(): payload_dict[name] = password else: # Simply populate the parameter with the existing value # (picks up hidden fields in the login form) payload_dict[name] = value for inputtag in formsoup.find_all(re.compile('(FORM|form)')): action = inputtag.get('action') # parsedurl = urlparse(idpentryurl) # idpauthformsubmiturl = "{scheme}://{netloc}{action}".format( # scheme=parsedurl.scheme, # netloc=parsedurl.netloc, # action=action) response = session.post(action, data=payload_dict, verify=self.sslverification) if response.status_code != 200: sys.exit(F'There was a problem logging in via ADFS. HTTP ' 'Status Code: {response.status_code}') assertion = common.get_saml_assertion(response) arn_to_assume = common.get_arns_from_assertion(assertion, self.args.account) sts_creds = common.get_sts_creds(arn_to_assume) try: common.write_credentials( self.args.profile, sts_creds ) except (NoOptionError, NoSectionError) as e: sys.exit(e.message) except requests.exceptions.ConnectionError as e: sys.exit(F'Could not connect to {self.idpurl}. {e}')
def login(self, username, password): self.auth = HttpNtlmAuth('nvidia.com\\' + username, password, self) result = self.get( 'https://ssoauth.nvidia.com/siteminderagent/ntlm/creds.ntc?CHALLENGE=&SMAGENTNAME=-SM-g29Lry3kCzPVuHmEXFRjSLOUUbtBVpl%2f7ptElB5BWROOZLaZSFXKsVGcly19D3p0&TARGET=-SM-http%3a%2f%2fnvplm%2envidia%2ecom%2fWindchill', auth=self.auth) if (result.status_code == 401): print(result) print('Login Failed') else: print('Login Successful')
def hasChild(serviceid, session, scom_ip, domain, username, password): response = (session.get( 'http://' + scom_ip + '/OperationsManager/data/objectInformation/' + serviceid, auth=HttpNtlmAuth(domain + '\\' + username, password))).json() service_data_tree = response.get("relatedObjects", []) if not service_data_tree: return False else: return True
def __init__(self, host: str, port: int = None, scheme: str = 'https', domain: str = None, username: str = None, password: str = None): super().__init__(host=host, port=port, scheme=scheme) if domain and username and password: _logger.debug('__SET NTLM AUTH') self._auth = HttpNtlmAuth(username=f'{domain}\\{username}', password=password) else: _logger.debug('__SET NTLM SSPI AUTH') self._auth = HttpNegotiateAuth()
def download_sharepoint(): print('Download Excel from iShare...') session = requests.Session() session.auth = HttpNtlmAuth(const.trend_domain_account, const.trend_password, session) resp = requests.get(const.code_line.trend_ishare_url, auth=session.auth) if resp.ok: with open(const.trend_ishare_download_file, 'wb') as file: file.write(resp.content)
def get(self, endpoint): if self.credential is not False: session.auth = HttpNtlmAuth(self.credential, self.password, session) headers['User-Agent'] = 'Windows' response = session.get('https://{0}/{1}'.format( self.server, endpoint), headers=headers, verify=self.root) return response.content
def get_root_xml(): ''' Use requests to grab .xml file containing calendar data returns root of xml (fromstring or the file version[test version]) ''' raw_website = requests.get( "Sharepoint Website", auth=HttpNtlmAuth('Domain\\Username','Password')) raw_text = raw_website.text return ET.fromstring(raw_text)