使用 azure DevOps rest 查找 PAT 范围 api

Find PAT scope using azure DevOps rest api

我正在编写脚本,我需要在其中查找 PAT 是否具有完整范围。

我在 Microsoft Docs 中找到了以下信息 -

获取https://vssps.dev.azure.com/{organization}/_apis/tokenadmin/personalaccesstokens/{subjectDescriptor}?api-version=6.0-preview.1

使用这个 API 我可以找到特定用户的所有 PATS 及其名称、范围和更多详细信息。

我不想在脚本中传递 PAT 名称然后找出它的作用域。

我想对给定的 PAT 令牌使用 PAT 令牌和 return 范围

有什么 API 可以实现这个吗?

I do not want to pass PAT name in script and then find out scope for it.

I want to use PAT token and return scope for the given PAT token

恐怕目前还没有通过 PAT 令牌而不是 PAT 名称 return PAT 范围的方法。

就像REST的return API Personal Access Tokens - List

    {
        "clientId": "00000000-0000-0000-0000-000000000000",
        "accessId": "439729fa-be4e-49b2-8530-263cf053d786",
        "authorizationId": "a451306e-621d-4a6c-8c54-9096493a40f9",
        "hostAuthorizationId": "00000000-0000-0000-0000-000000000000",
        "userId": "c1b9603c-da3a-410e-9e59-074dcee61dcc",
        "validFrom": "2021-01-07T00:00:00",
        "validTo": "2021-02-06T00:00:00",
        "displayName": "TestPATA1",
        "scope": "app_token",
        "targetAccounts": [
            "c519b80d-5d71-46b3-a8e0-3edf8c026ea2"
        ],
        "token": null,
        "alternateToken": null,
        "isValid": true,
        "isPublic": false,
        "publicData": null,
        "source": null,
        "claims": null
    },

响应正文中不包含 PAT 令牌的值,因此,我们可以将 PAT 令牌的值与每个 PAT 相关联。

另一方面,当我们创建 PAT 时,我们会收到消息:

Warning - Make sure you copy the above token now. We don't store it and you will not be able to see it again.

出于安全原因,Azure devops 不会保存我们创建的 PAT 值。所以在Azure devops中不会有保存或记录PAT值等属性,所以我们无法使用PAT token作为判断条件。