使用 python azure-devops 包时,如何使用 PAT 进行身份验证?
When using the python azure-devops package, how can I authenticate with a PAT?
GitHub 上的 Microsoft Azure-DevOps 包在 READ-ME 页面上提供了一个使用其库的单一用例
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients.get_core_client()
# Get the list of projects in the org
projects = core_client.get_projects()
# Show details about each project in the console
for project in projects:
pprint.pprint(project.__dict__)
我在网上四处寻找,没有找到任何文档或方法来弄清楚如何安装或使用 "mrest.authentication" 导入,因此无法创建与 Azure-DevOps 的连接或根本无法使用此库。
using pip install mrest
说网上没有找到匹配的包,我不明白微软为什么要把它包含在文档中,如果它是私有库。
如果有人知道与 azure-DevOps 包建立连接的解决方法、如何安装 mrest 包或访问 Azure DevOps REST 的更好方法 API 请告诉我,谢谢大家!
您将需要:
pip 安装 azure-devops
您需要安装 msrest 包,而不是 mrest:
pip3 install msrest
GitHub 上的 Microsoft Azure-DevOps 包在 READ-ME 页面上提供了一个使用其库的单一用例
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients.get_core_client()
# Get the list of projects in the org
projects = core_client.get_projects()
# Show details about each project in the console
for project in projects:
pprint.pprint(project.__dict__)
我在网上四处寻找,没有找到任何文档或方法来弄清楚如何安装或使用 "mrest.authentication" 导入,因此无法创建与 Azure-DevOps 的连接或根本无法使用此库。
using pip install mrest
说网上没有找到匹配的包,我不明白微软为什么要把它包含在文档中,如果它是私有库。
如果有人知道与 azure-DevOps 包建立连接的解决方法、如何安装 mrest 包或访问 Azure DevOps REST 的更好方法 API 请告诉我,谢谢大家!
您将需要: pip 安装 azure-devops
您需要安装 msrest 包,而不是 mrest:
pip3 install msrest