尝试连接到 TFSAPI 时出现错误 401

Error 401 while trying to connect to TFSAPI

我正在尝试使用 python TFSAPI 创建到 tfs 的连接, tfs 是本地的“http://*...:8080/tfs/default_Collection/Default 我收到了这个错误 requests.exceptions.HTTPError:401 客户端错误:未授权 url: 凭据是正确的,它们用于简单登录 试过这个:

from tfs import TFSAPI
client = TFSAPI(path, user = user, password = password)
workitem = client.get_workitem(100) # Test connection with Workitem id

然后像这样

import requests
from requests_ntlm import HttpNtlmAuth
username = ' '
password = " "
tfsApi = path
tfsResponse = requests.get(tfsApi,auth=HttpNtlmAuth(username,password))

两者都以相同的错误结束 回溯(最后一次调用): 文件“”,第 1 行,位于 文件 "C:\Users\ohad-ar\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\models.py",第 940 行,在 raise_for_status 中 引发 HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError:401 客户端错误:未授权 url: 欢迎任何建议,包括使用 python 连接 tfs api 的不同方式 非常感谢

from tfs import TFSAPI
personalAccessToken = "privetPersonalAccessToken"
path = "http://111.11.11.11:8080/tfs/HRCM_Collection/"
client = TFSAPI(path, pat=personalAccessToken ,project = "DefaultProject")
workitemId = 130000
workitem = client.get_workitem(workitemId )

这对我有用, 获取个人访问令牌使用
https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page