尝试通过代码C#连接时使用UCWA api并收到错误

时间:2016-05-20 11:44:26

标签: c# lync ucwa skypedeveloper

我正在使用UCWA api创建Lync会议URL但我在步骤中收到错误

它与LYNC有关,因此试图弄清楚如何解决。我的代码是

idLocation

并且最后4个变量的输出为

res_00.RequestMessage

idLocation = travellocationSet->getIdLocation();
travellocationSet = idLocation->getTravellocationSet();
idLocation = travellocationSet->getIdLocation();
travellocationSet = idLocation->getTravellocationSet();
// This will continue forever

res_00.Headers

string url_00   = ucwaMsRtcOAuth;   
var authDic_00  = new Dictionary<string, string>();  

authDic_00.Add("grant_type", "password");  
authDic_00.Add("username", String.Format("{0}\\{1}", ucwaAdDomain, ucwaAdUser));  
authDic_00.Add("password", ucwaAdPassword);  

httpClient.DefaultRequestHeaders.Remove("Accept");  
httpClient.DefaultRequestHeaders.Add("Accept", "application/vnd.microsoft.com.ucwa+xml");  

var res_00 = await httpClient.PostAsync(url_00, new FormUrlEncodedContent(authDic_00));  

string res_00_request   = res_00.RequestMessage.ToString();  
string res_00_headers   = res_00.Headers.ToString();  
string res_00_status    = res_00.StatusCode.ToString();  
var res_00_content      = await res_00.Content.ReadAsStringAsync();  

res_00.StatusCode

Method: POST, RequestUri: 'https://lynceu1webint.MYCOMPANYNAME.com/WebTicket/oauthtoken', 
Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
  Accept: application/vnd.microsoft.com.ucwa+xml
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 72
}

res_00.Content

Pragma: no-cache
X-Ms-diagnostics: 28020;source="GDLYNPRFEWP01P.corp.MYCOMPANYNAME.com";reason="No valid security token."
X-MS-Server-Fqdn: GDLYNPRFEWP01P.corp.MYCOMPANYNAME.com
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Cache-Control: no-store
Date: Fri, 20 May 2016 11:12:09 GMT
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET

1 个答案:

答案 0 :(得分:0)

您可以看到错误响应的一些潜在原因:

  • 域名\用户名组合不正确
  • 密码不正确
  • 授权字符串不正确

如果您打算将域名和密码与密码一起使用,请确保您的授权字符串类似于:

  

grant_type =密码&安培;域\用户名&安培;密码= *******

如果仍然无效,则可能需要将用于登录该用户的SIP /帐户提供给桌面版Skype for Business。此授权字符串如下所示:

  

grant_type =密码&安培; username@domain.com&密码= *******