【问题标题】:Using UCWA api and getting error when trying to connect through code C#尝试通过代码 C# 连接时使用 UCWA api 并出现错误
【发布时间】:2016-09-17 16:06:15
【问题描述】:

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

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

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();  

最后4个变量的输出为

res_00.RequestMessage

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.Headers

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

res_00.StatusCode

BadRequest

res_00.Content

{"error":"invalid_grant"}

【问题讨论】:

    标签: c# lync ucwa skypedeveloper


    【解决方案1】:

    您看到该错误响应有几个潜在原因:

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

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

    grant_type=password&domain\username&password=*******

    如果这仍然不起作用,您可能需要提供用于将该用户登录到桌面版 Skype for Business 的 SIP/帐户。此授权字符串如下所示:

    grant_type=password&username@domain.com&password=*******

    【讨论】:

    • 这无济于事,我仍然遇到同样的错误。需求被推迟了,现在我再次着手解决这个问题,发现诊断问题并不困难,因为没有关于它及其解决方案的全面文档。
    • 如果您仍然看到无效授权,这一定意味着您提供的字符串格式不正确。如果您可以将其与凭据的虚拟数据一起发布,则可能会找出它不正确的地方并修复它。
    • 您好,谢谢,这个问题得到了解决,我在使用 lyncdiscover.domain.com 并将其替换为 lyncdiscoverinternal.domain.com,现在它可以工作了。
    • @Chandikumar 感谢兄弟的回答!也为我工作! (有趣的是,它有时会(?)在不添加内部单词的情况下工作。0个想法为什么。你应该将你的解决方案添加到主要问题。
    • 自动发现会命中两个位置:lyncdiscover.domain.com 和 lyncdiscoverinternal.domain.com。内部域通常只能从您的网络内部访问。
    猜你喜欢
    • 2013-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多