Search code examples
azurepowershellazure-devops

Managing Azure DevOps PATs with non-interactive login


I'm able to manage the Azure DevOps Personal Access Tokens through the REST API if the interactive logon is enabled for the account. However, my scope is to disable the interactive logon. I've tried with an App Registration/Service Principal, but I haven't been able to, it seems that Microsoft doesn't allow managing PATs through this? Is managing PATs with non-interactive sign in possible?

Tried to create a new PAT while logged in with a service pricipal, ended up with an unclear error.


Solution

  • I've tried with an App Registration/Service Principal, but I haven't been able to, it seems that Microsoft doesn't allow managing PATs through this? Is managing PATs with non-interactive sign in possible?

    You can't use service principals to create or revoke PATs directly. It's mentioned in doc:

    enter image description here

    But you can use service principal to grant Microsoft Entra tokens, and use the token with PAT Lifecycle Management API to create the PAT.

    You can find the details steps in my answer here and similar answer here.

    Please also check official doc Manage personal access tokens (PATs) using REST API for the details.