Reputation: 195
I'm creating a asp.net web application which uses AD authentication to login. This application provides some services which call TFS RestApi that uses AD authentication as well. I need to pass login information to TFS and I don't want to keep username/password at all after signing. Is there any way just to pass for example a current session token or identity to TFS Rest Api? Somehow similar to SSO?
Thanks
Upvotes: 2
Views: 770
Reputation: 195
As @PatrickLu mentioned we need to enable impersonation in web.config. Another thing, if you use HttpClient since it's async it's not gonna work:
var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials=true})
HttpResponseMessage response = client.GetAsync("your-tfs-url").Result;
So it's better to use WebClient
WebClient wc = new WebClient();
wc.UseDefaultCredentials = true;
wc.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/json;
charset=utf-8");
var result=wc.DownloadString("http://yourtfs-url");
Upvotes: 0
Reputation: 51143
You could try below ways to do this:
Note:
Upvotes: 1