1

I am logging into az cli using correct token: echo my_pat | az devops login

But I see the following error while getting the existing repositories in a project:

az repos list --org {ado_org_url} --project {ado_project} --query '[*].name'

ERROR: The requested resource requires user authentication: https://dev.azure.com/my_org/my_project/\_apis/git/repositories

Am I missing any settings while setting up my pat? How can I get rid of this error?

Rishabh
  • 35
  • 1
  • 6

1 Answers1

0

You don't want to use the az devops login if you already set an AZURE_DEVOPS_EXT_PAT Environment Variable. If you not set an AZURE_DEVOPS_EXT_PAT Environment Variable set it first and do your CLI Task.

The az devops commands now enable sign-in with az login, you don't need to give a token if you've already signed in with az login interactively or with a username and password. However, you can't use az login to log in as the service principal. A PAT is required in that case.

If you still need to log in by using az devops login it requires the User Authentication. For that, you have to login using Service Principle

 "user": {
    "name": "***",
    "type": "servicePrincipal"
  }

References

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
  • Thank you. Setting the environment variable instead of using 'az devops login' helped get rid of this error. – Rishabh Mar 29 '22 at 18:29