简体   繁体   English

Azure DevOps 的客户端凭据流

[英]Client Credentials Flow for Azure DevOps

I have been looking at this issue for days and I know from experience that I usually work these things out but this time I have hit a brick wall.我已经研究这个问题好几天了,我从经验中知道我通常会解决这些问题,但这次我遇到了麻烦。

Scenario设想

I have a python app that gets instantiated inside an Azure DevOps YAML pipeline.我有一个在 Azure DevOps YAML 管道中实例化的 Python 应用程序。 The app calls the Azure DevOps REST API to create a repository应用调用 Azure DevOps REST API 来创建存储库

The app uses a PAT (personal access token) to authenticate该应用程序使用 PAT(个人访问令牌)进行身份验证

Firstly issue is, a personal access token is connected to me as a human user.第一个问题是,个人访问令牌以人类用户的身份连接到我。 If I leave the company the PAT will be revoked which is not good for an app that needs to run in a non-user context.如果我离开公司,PAT 将被撤销,这对需要在非用户环境中运行的应用程序不利。

So now I want to setup my Python app to authenticate to the Azure DevOps REST API using client credentials flow.所以现在我想设置我的 Python 应用程序以使用客户端凭据流对 Azure DevOps REST API 进行身份验证。

My issue is, I can't find consistent information about this.我的问题是,我找不到关于此的一致信息。

I have created an app in Azure DevOps:我在 Azure DevOps 中创建了一个应用程序:

在此处输入图片说明

My plan would be to get this all working in Postman and then port my finding to Python code.我的计划是让这一切在 Postman 中工作,然后将我的发现移植到 Python 代码中。 So really, I am looking for help with the setup I do in Postman and I can work the rest out myself in Python.所以真的,我正在寻求有关我在 Postman 中进行的设置的帮助,其余的我可以在 Python 中自己解决。

Many posts talk about Azure DevOps and Azure AAD (Azure Active Directory) together but, seeing as I create my app registration in Azure DevOps, as shown in the picture, I don't see why I would do anything in AAD.许多帖子同时讨论 Azure DevOps 和 Azure AAD(Azure Active Directory),但是,当我在 Azure DevOps 中创建应用注册时,如图所示,我不明白为什么我会在 AAD 中做任何事情。 (Note, my Azure DevOps instance was created outside Azure. Azure knows nothing about my Azure DevOps instance) (注意,我的 Azure DevOps 实例是在 Azure 之外创建的。Azure 对我的 Azure DevOps 实例一无所知)

Any pointers to the CORRECT information about how to do this would be good.任何指向有关如何执行此操作的正确信息的指针都会很好。 And remember, I definitely need the client credentials type flow.请记住,我绝对需要客户端凭据类型流。 There is no human interaction between my app and the Azure DevOps REST API.我的应用程序和 Azure DevOps REST API 之间没有人工交互。

Update更新

Here is what I have in Postman right now:这是我现在在 Postman 中的内容: 在此处输入图片说明 Note:笔记:

  • You can see the check boxes which I am using to toggle application/x-www-form-urlencoded key / value pairs on and off您可以看到我用来打开和关闭 application/x-www-form-urlencoded 键/值对的复选框
  • the resource - 499b84ac-1321-427f-aa17-267ca6975798 is apparently the GUID for Azure DevOps and doesn't change资源- 499b84ac-1321-427f-aa17-267ca6975798显然是 Azure DevOps 的 GUID,不会改变
  • If I look inside the HTML from the 500 error I see this: Could not find partition for hostId: 499b84ac-1321-427f-aa17-267ca6975798 which is the DevOps resource GUID mentioned above.如果我从 500 错误中查看 HTML,我会看到:找不到 hostId 的分区:499b84ac-1321-427f-aa17-267ca6975798 ,这是上面提到的 DevOps 资源 GUID。

And here is the 500 error I get from Azure Devops:这是我从 Azure Devops 得到的 500 错误: 在此处输入图片说明

It's all very confusing but I am sure I just need to tweak one or two things to get it working.这一切都非常令人困惑,但我确信我只需要调整一两件事即可使其正常工作。

I want to use client_credential flow in Azure DevOps for the same reasons as you!出于与您相同的原因,我想在 Azure DevOps 中使用 client_credential 流! Last time I spoke to support they told me it was planned for Q3 2020 .上次我与支持人员交谈时,他们告诉我计划在 2020 年第三季度进行 Reviewing the roadmap I can't see it on there at the moment. 查看路线图,我目前在那里看不到它。 I also couldn't see any feature requests currently raised onDev Community so you could consider trying to raise the profile of this issue on there.我也看不到Dev Community目前提出的任何功能请求,因此您可以考虑尝试在那里提高此问题的知名度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 requests-oauthlib 自动刷新客户端凭据流中的 Bearer 令牌? - requests-oauthlib auto refresh Bearer token in client credentials flow? 在 Azure DevOps 中自动创建文件夹? - Automate folder creation in Azure DevOps? Azure Devops 部署 Python Azure Z86408593C34AF77FDD90DF923 - Azure Devops deploying Python Azure Function not working 在 Azure Devops 中将参数传递给 python 脚本 - Passing arguments to python script in Azure Devops 为什么 Azure DevOps 服务器交错 output - Why Does Azure DevOps Server interleave output 将 Azure DevOps 管道详细信息发送到 SIEM - Send Azure DevOps Pipeline Details to SIEM 在 Azure Devops 发布管道中启动 Python 看门狗 - Launching a Python watchdog in an Azure Devops Release pipeline 在 Azure Devops Pipeline 中运行 Python 代码并将输出导出到 Devops Repos ($(Build.SourcesDirectory)) 中的文件夹 - Run Python Code within Azure Devops Pipeline and Export output to folder in Devops Repos ($(Build.SourcesDirectory)) 如何通过 azure-devops-python-api 获取仪表板列表 - How to get a list of dashboards through azure-devops-python-api 运行 Azure DevOps 管道存在 ##[error]Bash exited with code '1' - Running Azure DevOps pipeline exists with ##[error]Bash exited with code '1'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM