首页 > 解决方案 > 如何使用它的 python 客户端 API 对 Azure DevOps 进行身份验证?

问题描述

我正在尝试通过为此编写 python 脚本来自动在 azure devops 中创建用户。为此,我使用了 azure-devops 的 python 客户端 API。

截至目前,身份验证是使用个人访问令牌(PAT)完成的:

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication

personal_access_token = <myPAT>
organization_url = 'https://dev.azure.com/<myOrganization>'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

实际上,我有一个使用 Graph API 的脚本,它通过 ADAL 向 Azure AD 进行身份验证。这意味着我已经在我们的 Azure AD 中注册了一个应用程序,该应用程序是为使用 Graph API 而创建的。

我可以使用此应用程序及其客户端 ID 对 Azure DevOps 服务进行身份验证吗?如何将此身份验证方法与 Python 客户端 API 一起使用?

这篇关于 OAuth 2.0 身份验证方法的文章是否指向相同?: https ://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?toc=%2Fazure%2Fdevops%2Forganizations%2Ftoc.json&bc=%2Fazure%2Fdevops%2Forganizations%2Fbreadcrumb %2Ftoc.json&view=azure-devops#register-your-app

我很困惑,因为它说要在 azure devops 中创建应用程序,而不是在 azure AD 中。

如果可能的话,任何人都可以通过澄清这一点并解释进行此身份验证的步骤来帮助我吗?

标签: pythonauthenticationazure-devopsazure-active-directoryclient

解决方案


推荐阅读