• Register
0 votes
355 views

Problem :

We upgraded to TFS 2017 and our API calls stopped working and we started receiving following error:
"TF400813: Resource not available for anonymous access. Client authentication required.". Anything in [] brackets was replaced.

I amt don’t know why the code block is having issues.

using (var myclient = new HttpClient(new HttpClientHandler()))
{
myclient.Timeout = TimeSpan.FromMinutes(3);
myclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes("[domain]\\[username]:[password]")));
myclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage myresponse = myclient.GetAsync($"https://[server]:8080/tfs/[node]/[node]/_apis/build/builds?api-version=2.0&definitions={buildDefinitionNumber}&resultFilter={resultFilter}&$top={maxBuildCount}").Result;
var myresult = myresponse.Content.ReadAsStringAsync().Result;
return (JArray)JObject.Parse(myresult)["value"];
}
6 5 3
7,540 points

1 Answer

0 votes

Solution :

As a solution on yhe issue, I just created a personal access token (PAT) and I was able to get authenticated using that PAT.

This is not the ideal way as I am putting my personal access token in the code to get this working. I was using the service account so now I am trying to understand that how can I create a PAT for the service account and/or I am still trying to figure out a way to make it work like it once did because I can not login to the TFS dashboard with the service account.

Please refer the following Updated Code:

string mycredentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", "<PAT>")));
myclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", mycredentials);

 

Further Readings :

I refered below articles:

https://www.visualstudio.com/en-us/docs/integrate/get-started/authentication/pats

https://www.visualstudio.com/en-us/docs/integrate/get-started/rest/samples

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 232 views
232 views
Problem : I have created one of the WCF service and deployed it on the Server. When I browse this service it gives me positive response with the wsdl URL. Now I am trying to test my service through the WCF Test client. It shows me ... factory) The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
asked Jan 23 jwilliam 3.9k points
0 votes
1 answer 191 views
191 views
Problem : I want to send mails using my web application. But my below code is showing me the below error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send ... false; mysmtp.Timeout = 600000; } // Passing values to smtp object mysmtp.Send(myfromAddress, mytoAddress, mysubject, mybody); } } }
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 120 views
120 views
Problem : I am very new to node.js and MySQL and I have just started setting up and also trying out some basic code. But, I am unable to make even the simple connection to a server for some reason. I have also installed a newest MySQL ... ; console.log("Connected!"); }); My Error: &ldquo;Client does not support authentication protocol requested by server consider upgrading mysql client&rdquo;
asked Jan 30 jwilliam 3.9k points
0 votes
1 answer 59 views
59 views
Problem: I have very recently integrated my Tomcat 7 in Eclipse. If I start Tomcat 7 using Eclipse then it shows that my Tomcat is up and running but if I go to http://localhost:8080 in the browser then it gives me following error: HTTP Status 404 - / type Status report ... is already in use by some other service but that did not work either for me. How can I fix above error related to Tomcat 7?
asked Aug 2 Raphael Pacheco 4.9k points