set connect access token
This commit is contained in:
parent
6fd05670ac
commit
a3d553a7fb
|
@ -399,11 +399,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
/// <returns>stream on success, null on failure</returns>
|
||||
public async Task<Stream> Post(HttpRequestOptions options, Dictionary<string, string> postData)
|
||||
{
|
||||
var strings = postData.Keys.Select(key => string.Format("{0}={1}", key, postData[key]));
|
||||
var postContent = string.Join("&", strings.ToArray());
|
||||
|
||||
options.RequestContent = postContent;
|
||||
options.RequestContentType = "application/x-www-form-urlencoded";
|
||||
options.SetPostData(postData);
|
||||
|
||||
var response = await Post(options).ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent Condition=" '$(ConfigurationName)' != 'Release Mono' ">if '$(ConfigurationName)' == 'Release' (
|
||||
xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition=" '$(ConfigurationName)' != 'Release Mono' " />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent Condition=" '$(ConfigurationName)' != 'Release Mono' ">if '$(ConfigurationName)' == 'Release' (
|
||||
xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace MediaBrowser.Common.Net
|
||||
|
@ -111,5 +112,14 @@ namespace MediaBrowser.Common.Net
|
|||
|
||||
LogRequest = true;
|
||||
}
|
||||
|
||||
public void SetPostData(IDictionary<string,string> values)
|
||||
{
|
||||
var strings = values.Keys.Select(key => string.Format("{0}={1}", key, values[key]));
|
||||
var postContent = string.Join("&", strings.ToArray());
|
||||
|
||||
RequestContent = postContent;
|
||||
RequestContentType = "application/x-www-form-urlencoded";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user