mirror of
https://github.com/bitwarden/android.git
synced 2024-11-02 08:03:56 +03:00
29 lines
904 B
C#
29 lines
904 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>();
|
|
var appIdService = Resolver.Resolve<IAppIdService>();
|
|
Headers.Add("Authorization", $"Bearer {authService.Token}");
|
|
if(!string.IsNullOrWhiteSpace(appIdService.AppId))
|
|
{
|
|
Headers.Add("DeviceIdentifier", appIdService.AppId);
|
|
}
|
|
}
|
|
|
|
public TokenHttpRequestMessage(object requestObject)
|
|
: this()
|
|
{
|
|
var stringContent = JsonConvert.SerializeObject(requestObject);
|
|
Content = new StringContent(stringContent, Encoding.UTF8, "application/json");
|
|
}
|
|
}
|
|
}
|