set connect access token

This commit is contained in:
Luke Pulverenti
2014-09-02 22:30:05 -04:00
parent 6fd05670ac
commit a3d553a7fb
5 changed files with 33 additions and 11 deletions

View File

@@ -10,7 +10,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -113,7 +112,12 @@ namespace MediaBrowser.Server.Implementations.Connect
{
var url = "Servers";
url = GetConnectUrl(url);
var postData = new Dictionary<string, string> {{"name", _appHost.FriendlyName}, {"url", wanApiAddress}};
var postData = new Dictionary<string, string>
{
{"name", _appHost.FriendlyName},
{"url", wanApiAddress}
};
using (var stream = await _httpClient.Post(url, postData, CancellationToken.None).ConfigureAwait(false))
{
@@ -131,12 +135,24 @@ namespace MediaBrowser.Server.Implementations.Connect
var url = "Servers";
url = GetConnectUrl(url);
url += "?id=" + ConnectServerId;
var postData = new Dictionary<string, string> {{"name", _appHost.FriendlyName}, {"url", wanApiAddress}};
// TODO: Add Access-Key http request header
var options = new HttpRequestOptions
{
Url = url,
CancellationToken = CancellationToken.None
};
options.SetPostData(new Dictionary<string, string>
{
{"name", _appHost.FriendlyName},
{"url", wanApiAddress}
});
options.RequestHeaders.Add("X-Connect-Token", ConnectAccessKey);
// No need to examine the response
using (var stream = await _httpClient.Post(url, postData, CancellationToken.None).ConfigureAwait(false))
using (var stream = (await _httpClient.Post(options).ConfigureAwait(false)).Content)
{
}
}