0

TFS Authentication failed. Error code: Unauthorized

I am entering domain\user.name and pass

This is the log

2019-01-10 17:19:09.5036 | DEBUG | Web.Controllers.TfsController | 86 | Checking connection to 'https://dc-tfs-app.datys.cu:443/tfs/DatysHolguin'
2019-01-10 17:19:09.5904 | DEBUG | Web.Controllers.TfsController | 86 | Received Unauthorized status code
2019-01-10 17:19:09.5904 | INFO | Web.Utils.EventLogger | 86 | {"e":"Tfs.UpdatingSettings","p":{"CredentialsType":"Password","AutoDetectSettings":false}}
2019-01-10 17:19:09.7041 | WARN | Web.Controllers.TfsController | 86 | Cannot save settings Web.Common.AuthenticationException: Need credentials. ---> Web.Common.AuthenticationException: Authentication failed. Error code: Unauthorized
at Web.Services.Tfs.TfsAdapterBase.EnsureSuccessfulResponse(HttpResponseMessage response) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 466
at Web.Services.Tfs.TfsAdapterBase.<>c__DisplayClass36_0`1.<<TfsGetWithHeaders>b__0>d.MoveNext() in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 372
--- End of stack trace from previous location where exception was thrown ---
at Web.Services.Tfs.TfsAdapterBase.<>c__DisplayClass38_0`1.<<InvokeWithAuthRetryAndLimiting>b__0>d.MoveNext() in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 404
--- End of stack trace from previous location where exception was thrown ---
at Web.Services.Tfs.Tfs2015Adapter.InvokeWithAuthRetry[T](Func`1 func) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/Tfs2015Adapter.cs:line 620
--- End of inner exception stack trace ---
at Web.Services.Tfs.Tfs2015Adapter.InvokeWithAuthRetry[T](Func`1 func) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/Tfs2015Adapter.cs:line 625
at Web.Services.Tfs.TfsAdapterBase.InvokeWithAuthRetryAndLimiting[T](Func`1 func) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 404
at Web.Services.Tfs.TfsAdapterBase.TfsGetWithHeaders[T](String uri, TfsConnectionSettings settings) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 361
at Web.Services.Tfs.TfsAdapterBase.TfsGetMultiple[T](String uri, TfsConnectionSettings settings, Boolean onlyFirstBatch) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/TfsAdapterBase.cs:line 334
at Web.Services.Tfs.Tfs2015Adapter.VerifyConnectionSettings(TfsConnectionSettings settings) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/Tfs2015Adapter.cs:line 55
at Web.Services.Tfs.MultiVersionTfsAdapter.DetectVersion(TfsConnectionSettings settings) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/MultiVersionTfsAdapter.cs:line 51
at Web.Services.Tfs.MultiVersionTfsAdapter.VerifyConnectionSettings(TfsConnectionSettings settings) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/Tfs/MultiVersionTfsAdapter.cs:line 77
at Web.Services.ServerManager.SetConnectionSettings(IConnectionSettings connectionSettings) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Services/ServerManager.cs:line 90
at Web.Controllers.TfsController.UpdateConnectionSettings(Guid instanceId, TfsConnectionSettingsModel connectionSettingsModel) in /home/buildagent/build_agent/agent-1/_work/2/s/Desktop/LocalWeb/Controllers/TfsController.cs:line 139
2019-01-10 17:19:09.7144 | INFO | Web.Utils.EventLogger | 86 | {"e":"Tfs.FailedToUpdateSettings","p":{"Message":"Authentication failed. Error code: Unauthorized"}}

1 reply

This can happen if "Basic" authentication is disabled for TFS. Please see this article on how to enable it - https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/auth/tfs-basic-auth?view=vsts

Alternatively, if your TFS server has NTLM authentication enabled, and you work on Windows machine, you can try to "Use my Windows credentials" when you connect to TFS in CatLight.