15 lines
530 B
C#
15 lines
530 B
C#
using System.Net.Http.Headers;
|
|
using System.Text;
|
|
|
|
namespace adas_core.module.Relays.Utils;
|
|
|
|
public static class HttpUtils
|
|
{
|
|
public static HttpRequestHeaders AddBasicAuth(string username, string password, HttpRequestHeaders headers)
|
|
{
|
|
var auth = Encoding.ASCII.GetBytes($"{username}:{password}");
|
|
var clientAuthorizationHeader = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(auth));
|
|
headers.Add("Authorization", clientAuthorizationHeader.ToString());
|
|
return headers;
|
|
}
|
|
} |