bitwarden-android/src/App/Utilities/TokenHttpRequestMessage.cs
Kyle Spearrin 24a5a16723 wip
2016-05-03 19:49:49 -04:00

24 lines
678 B
C#

using System.Net.Http;
using System.Text;
using Bit.App.Abstractions;
using Newtonsoft.Json;
using XLabs.Ioc;
namespace Bit.App
{
public class TokenHttpRequestMessage : HttpRequestMessage
{
public TokenHttpRequestMessage()
{
var authService = Resolver.Resolve<IAuthService>();
Headers.Add("Authorization", $"Bearer {authService.Token}");
}
public TokenHttpRequestMessage(object requestObject)
: this()
{
var stringContent = JsonConvert.SerializeObject(requestObject);
Content = new StringContent(stringContent, Encoding.UTF8, "application/json");
}
}
}