【发布时间】:2020-07-21 13:11:12
【问题描述】:
(使用 C#) 我正在尝试进行身份验证,但它总是返回失败。我知道我的用户名和密码是正确的。如果这很重要,我们可能会使用 OSLC 1.0。我不确定,但我在 services.xml 文件中看到过几次。 website 我正在使用 3.0.也许有区别?知道我做错了什么吗?
Debug.Log("Authentication Required");
// tried with just j_security_check as well (without "authenticated") as he seems to do both on the site
HttpWebRequest _formPost = (HttpWebRequest)WebRequest.Create(localhost + "authenticated/j_security_check");
_formPost.Method = "POST";
_formPost.Timeout = 30000;
_formPost.CookieContainer = request.CookieContainer;
_formPost.Accept = "text/xml";
_formPost.ContentType = "application/x-www-form-urlencoded";
Byte[] _outBuffer = Encoding.UTF8.GetBytes("j_username=coolcat&j_password=bestPassEvar"); //store in byte buffer
_formPost.ContentLength = _outBuffer.Length;
Stream _str = _formPost.GetRequestStream();
_str.Write(_outBuffer, 0, _outBuffer.Length); //update form
_str.Close();
//FormBasedAuth Step2:submit the login form and get the response from the server
HttpWebResponse _formResponse = (HttpWebResponse)_formPost.GetResponse();
string _rtcAuthHeader = _formResponse.Headers["X-com-ibm-team-repository-web-auth-msg"];
//check if authentication has failed
if ((_rtcAuthHeader != null) && _rtcAuthHeader.Equals("authfailed"))
{
Debug.Log("Authentication Failed");
return;
}
【问题讨论】:
标签: c# httpwebrequest rational-team-concert ibm-jazz oslc