How do you revoke someone else's PAT?

最后都变了- 提交于 2021-02-11 16:40:18

问题


If I am the Project Collection Administrator in dev.azure.com for a particular organization, then how do I revoke someone else's Personal Access Token?


回答1:


how do I revoke someone else's Personal Access Token?

This is acutually provided in MSDN documentation Revoke personal access tokens for organization users.

If you are the PCA of your organization, please follow the doc Revoke PATs to revoke PATs for your organization users.

Use the Token Revocations or the PowerShell script provided to call the REST API.




回答2:


I have managed to do it by following these steps using Postman:

  1. First we need to get the subject descriptor, which is the user’s SID in Azure AD:

    GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=5.1-preview.1

  2. Now we need to list of the PATs for that user. (Lists of all the session token details of the personal access tokens (PATs) for a particular user:

    GET https://vssps.dev.azure.com/{organization}/_apis/tokenadmin/personalaccesstokens/{subjectDescriptor}?api-version=5.0-preview.1)

We got the {subjectDescriptor} in the "description" field in step one and this is the SID of the Azure AD user.

  1. Now we finally revoke that PAT for the particular user: (Revokes the listed OAuth authorizations.

    POST https://vssps.dev.azure.com/{organization}/_apis/tokenadmin/revocations?api-version=5.0-preview.1)

The "authorizationId" that we got in the results from step 2 need to be input the POST request as a JSON object. It is an array below, so that it supports multiple revokations.

[
 {
   "authorizationId":  "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
 }
]


来源:https://stackoverflow.com/questions/59770400/how-do-you-revoke-someone-elses-pat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!