huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
45 stars 22 forks source link

##[error]Failed request: (401) #121

Closed wangyan0821 closed 4 years ago

wangyan0821 commented 4 years ago

I wanted to trigger a build which in another tfs server, and I used all three Authentication Method, but none of them was successed. The error is below:

2019-12-23T02:44:41.1718180Z Using Custom Team Project 2019-12-23T02:44:41.1718457Z Team Project: TestManager 2019-12-23T02:44:41.1718547Z Using Custom Collection Url 2019-12-23T02:44:41.1721969Z Server URL: http://tfs/DefaultCollection 2019-12-23T02:44:41.1727281Z Using Basic Authentication 2019-12-23T02:44:41.2584655Z ##[error]Failed request: (401)

Does this tool not support http ?

huserben commented 4 years ago

Hi @wangyan0821

The error code 401 suggests that the authentication failed.

As you mentioned you used all 3 methods, the OAuth Token will not work when trying to queue anything on a different server or collection, only on the one your build is running already, so that's expected to fail. I think Basic Authentication (respectively "Alternate Credentials") have to be manually allowed and will be deprecated soon (in Azure DevOps at least).

So ideally you would go with a PAT to make it work on the other TFS. The question is why it didnt work for you. Did you make sure that you created the PAT on the target TFS and it has the necessary permissions (Build (read and execute))?

Also check out the docs regarding specialties when queuing on a different server/collection.

Can you check this out and see whether it helps - if not please provide me a log of the run when using a Personal Access Token.

wangyan0821 commented 4 years ago

Hi, huserben Thanks very much. It was worked after I did the things below:

  1. set the OAuth Token not work
  2. used PAT and make sure that the PAT on the target TFS has the necessary permissions