尝试通过python脚本将文件上载到sharepoint时,会出现由于用户名或密码无效而导致的验证凭据错误
我正在尝试将文件上传到已经创建的sharpoint文件夹结构,我使用了两个文件 配置模板-尝试通过python脚本将文件上载到sharepoint时,会出现由于用户名或密码无效而导致的验证凭据错误,python,excel,sharepoint,upload,Python,Excel,Sharepoint,Upload,我正在尝试将文件上传到已经创建的sharpoint文件夹结构,我使用了两个文件 配置模板- config = dict() config['sp_user'] = 'abs@xyz.com' config['sp_password'] = 'pass@123' config['sp_base_path'] = 'https://xyz.sharepoint.com' config['sp_site_name'] = '/sites/bootromandhsesecurity/Shared%20D
config = dict()
config['sp_user'] = 'abs@xyz.com'
config['sp_password'] = 'pass@123'
config['sp_base_path'] = 'https://xyz.sharepoint.com'
config['sp_site_name'] = '/sites/bootromandhsesecurity/Shared%20Documents/Forms/AllItems.aspx?originalPath=0d66ed181f1&id=%2Fsites%2Fbootromandhsesecurity%2FShared%20Documents%2F%2FSprint3'
config['sp_doc_library'] = 'Sprint3'
下一个文件是sharepoint\u上载-
import requests
from shareplum import Office365
from .config_template import config
def up():
# get data from configuration
username = config['sp_user']
password = config['sp_password']
site_name = config['sp_site_name']
base_path = config['sp_base_path']
doc_library = config['sp_doc_library']
file_name = "TestCaseDatabase\\Sprint3_Test_Report.xlsx"
# Obtain auth cookie
authcookie = Office365(base_path, username=username, password=password).GetCookies()
session = requests.Session()
session.cookies = authcookie
session.headers.update({'user-agent': 'python_bite/v1'})
session.headers.update({'accept': 'application/json;odata=verbose'})
session.headers.update({'X-RequestDigest': 'FormDigestValue'})
response = session.post( url=base_path + "/sites/" + site_name + "/_api/web/GetFolderByServerRelativeUrl('" + doc_library + "')/Files/add(url='a.txt',overwrite=true)",
data="")
session.headers.update({'X-RequestDigest': response.headers['X-RequestDigest']})
# perform the actual upload
with open( file_name, 'rb') as file_input:
try:
response = session.post(
url=base_path + "/sites/" + site_name + "/_api/web/GetFolderByServerRelativeUrl('" + doc_library + "')/Files/add(url='"
+ file_name + "',overwrite=true)",
data=file_input)
except Exception as err:
print("Some error occurred: " + str(err))
出于安全原因,此处更改了用户名和密码,但给出了正确的详细信息
对Office 365进行身份验证时出错。Office 365中的错误:“,”AADSTS50126:验证凭据时出错,原因是用户名或密码无效
出现上述错误。
我哪里做错了
另外,我一直在使用microsoft authenticator登录sharepoint文件夹,在那里我需要批准我在手机上的登录,这是导致问题的原因吗