4

I am using UCWA api to create Lync Meeting URL but I am getting error in a step,

and it is related to LYNC so trying to figure out how to resolve. My code is

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

and output of last 4 variable is as

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"}
Chandikumar
  • 139
  • 11

1 Answers1

2

There are a few potential reasons you are seeing that error response:

  • Incorrect domain\username combo
  • Incorrect password
  • Incorrect grant string

If you are intending to use domain and password with the password grant_type make sure your grant string resembles:

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

If that still does not work you may be required to provide the SIP/Account used to login in that user to the desktop version of Skype for Business. This grant string would look like:

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

ShelbyZ
  • 1,494
  • 1
  • 14
  • 32
  • 2
    This is not helping i am still getting the same error. Requirement was postponed and now i am again working on this and finding it little difficult to diagnose the issue as there is no comprehensive documentation about the it and its solution. – Chandikumar Oct 19 '16 at 06:58
  • 1
    If you are still seeing invalid grant it must mean that the string you are providing is in an incorrect format. If you could post that with dummy data for the credentials it might be possible to figure out what about it is incorrect and fix that. – ShelbyZ Oct 19 '16 at 14:57
  • 1
    Hi thanks, this problem got solved i was using lyncdiscover.domain.com and replaced it with lyncdiscoverinternal.domain.com, and now its working. – Chandikumar Oct 21 '16 at 06:25
  • 1
    @Chandikumar Thanks for the answer bro! Works for me too! (Interestingly, it would sometimes (?) work without adding the internal word. 0 ideas why. You should add your solution to the main question. – Vic Apr 11 '17 at 16:17
  • Autodiscovery hits two locations: lyncdiscover.domain.com and lyncdiscoverinternal.domain.com. The internal domain is usually only accessible from inside your network. – ShelbyZ Apr 11 '17 at 17:48