private byte[] GetGrant(Credentials credentials) { var grant = string.Format("grant_type={0}", credentials.GrantType); if (credentials.GrantType == Constants.Password) { grant = string.Format("{0}&username={1}&password={2}", grant, credentials.Username, credentials.Password); } // TODO: support online meeting join return Encoding.UTF8.GetBytes(grant); }
public async Task<AuthToken> GetAuthToken(Uri uri, Credentials credentials) { var request = new Request { Uri = uri, Method = HttpMethod.Post, Headers = new Dictionary<string, string> { { "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" } }, Data = GetGrant(credentials) }; if (credentials.GrantType == Constants.Windows) { var cache = new CredentialCache(); cache.Add(uri, "NTLM", new NetworkCredential(credentials.Username, credentials.Password, credentials.Domain)); request.Credentials = cache; } var response = await _proxy.ExecuteRequestAsync(request); return response?.Data?.FromBytes<AuthToken>(); }