【问题标题】:Validate the azure-devops PAT验证 azure-devops PAT
【发布时间】:2018-11-07 13:48:11
【问题描述】:

我从 azure devops 创建了一个 PAT。现在我已经创建了一个反应应用程序来处理所有的 api 逻辑。我现在有一个登录屏幕,用户需要输入 DEVOPS_TOKEN、ORGANISATION_NAME。如何在登录时验证用户令牌。我找不到任何用于验证用户的 api。

任何建议都会有所帮助。

【问题讨论】:

    标签: azure-devops azure-devops-rest-api


    【解决方案1】:

    经过一番调查,我找到了一种验证用户的方法。 Azure Devops 中有一个可用的 api:https://dev.azure.com/{ORGANISATION_NAME}/_apis/connectionData。

    需要在导致用户授权的标头参数中传递编码令牌。

    {
        "authenticatedUser": {
            "id": "123-13-131231231-123-123-123-123",
            "descriptor": "Microsoft.IdentityModel.Claims.ClaimsIdentity;123-13-131231231-123-123-123-123\\user@domain.com",
            "subjectDescriptor": "aad.Masdasdpadspoadsjpaodsjapodj",
            "providerDisplayName": "User Name",
            "isActive": true,
            "properties": {
                "Account": {
                    "$type": "System.String",
                    "$value": "user@domain.com"
                }
            },
            "resourceVersion": 2,
            "metaTypeId": 0
        },
        "authorizedUser": {
            "id": "123-13-131231231-123-123-123-123",
            "descriptor": "Microsoft.IdentityModel.Claims.ClaimsIdentity;123-13-131231231-123-123-123-123\\user@domain.com",
            "subjectDescriptor": "aad.Masdasdpadspoadsjpaodsjapodj",
            "providerDisplayName": "User Name",
            "isActive": true,
            "properties": {
                "Account": {
                    "$type": "System.String",
                    "$value": "user@domain.com"
                }
            },
            "resourceVersion": 2,
            "metaTypeId": 0
        },
        "instanceId": "123-13-131231231-123-123-123-123",
        "deploymentId": "123-13-131231231-123-123-123-123",
        "deploymentType": "hosted",
        "locationServiceData": {
            "serviceOwner": "123-13-131231231-123-123-123-123",
            "defaultAccessMappingMoniker": "PublicAccessMapping",
            "lastChangeId": 12313123,
            "lastChangeId64": 123123123
        }
    }
    

    【讨论】:

    • 你是怎么知道的?我找不到该 connectionData 端点的任何文档。
    • 我在博客评论区发现的
    猜你喜欢
    • 2021-12-27
    • 2019-11-20
    • 2022-08-19
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多