使用凭据和 RestSharp 从 TFS REST API 获取用户配置文件

Get user profile from TFS REST API using credentials with RestSharp

 var client = new RestClient("https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=1.0");
 var request = new RestRequest(Method.GET);
 var authenHeader = new AuthenticationHeaderValue("Bearer",
                    Convert.ToBase64String(
                    System.Text.ASCIIEncoding.ASCII.GetBytes(
                    string.Format("{0}:{1}", username, password))));
 request.AddHeader("Authorization", authenHeader.ToString());
 request.AddHeader("Accept", "application/json");
 IRestResponse response = client.Execute(request);

回复:

StatusCode: NonAuthoritativeInformation, 
Content-Type: text/html; 
.
.

或者这个请求只能使用个人访问令牌来获取?

您必须将 OAuth 与配置文件 API 一起使用,它不支持基本身份验证。