jasminsehic / infinity.net

.NET API for Azure DevOps and DevOps Server formerly Visual Studio Online and Team Foundation Server
Other
36 stars 13 forks source link

Error: {"Unauthorized"} #18

Closed jaredcnance closed 8 years ago

jaredcnance commented 8 years ago

So, I copied the example verbatim and am targeting a brand new account. I am 100% certain the credentials are correct. Is there something I am missing?

var client = new TfsClient(new TfsClientConfiguration
      {
        Url = new Uri(collectionUri),
        Credentials = new NetworkCredential(username,password),
      });

      IEnumerable<Project> projects = new List<Project>();
      Task.Run(async () =>
      {
        projects = await client.Project.GetProjects(); // <-- throws {"Unauthorized"}
      }).Wait();
ethomson commented 8 years ago

Are you using VSTS or TFS on-premises? If the latter, what version?

jaredcnance commented 8 years ago

VSTS

ethomson commented 8 years ago

Anything tricky going on in your account like 2FA?

jaredcnance commented 8 years ago

No I haven't done anything special with account auth

ethomson commented 8 years ago

You could also get an Unauthorized if your collection URL was not specified correctly... So that's one thing to double-check. (https and not http, etc.)

Otherwise, it might be interesting to look at fiddler to make sure that nothing jumps out at you as being broken. But I'll take a look at things this evening to make sure that nothing has bitrotted against VSTS lately.

jaredcnance commented 8 years ago

Okay, I appreciate it. The Uri looks fine. But, I also can't curl it either using the examples so I'm guessing it's not an issue with your library

curl -u {username}[:{password}] https://{account}.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0

respnds with:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="....">here</a>.</h2>
</body></html>
jaredcnance commented 8 years ago

It looks like this has to do with a web filter at my work that is proxying requests. I guess the auth just isn't making it across the proxy. I was able to make requests from a different network. Thanks for taking the time to look into this.

ethomson commented 8 years ago

Thanks for the followup! Glad things are working now.