[CHANGE] Reworked client creation
This commit is contained in:
@@ -10,16 +10,27 @@ public static class AuthenticationUtilities
|
||||
private const string HeaderScheme = "SAPISIDHASH";
|
||||
|
||||
// Dave Thomas & windy for updated answer @ https://stackoverflow.com/a/32065323/9948300
|
||||
public static AuthenticationHeaderValue? GetSapisidHashHeader(string datasyncId, string sapisid, string origin)
|
||||
public static AuthenticationHeaderValue GetSapisidHashHeader(string datasyncId, string sapisid, string origin)
|
||||
{
|
||||
var strHash = GetSapisidHash(datasyncId, sapisid, origin);
|
||||
return strHash == null ? null : new AuthenticationHeaderValue(HeaderScheme, strHash);
|
||||
return new AuthenticationHeaderValue(HeaderScheme, strHash);
|
||||
}
|
||||
|
||||
public static string? GetSapisidHash(string datasyncId, string sapisid, string origin, string? time = null)
|
||||
public static string GetSapisidHash(string datasyncId, string sapisid, string origin, string? time = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(datasyncId) || string.IsNullOrWhiteSpace(sapisid) || string.IsNullOrWhiteSpace(origin))
|
||||
return null;
|
||||
if (string.IsNullOrWhiteSpace(datasyncId))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(datasyncId));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(sapisid))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(sapisid));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(origin))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(origin));
|
||||
}
|
||||
|
||||
datasyncId = datasyncId.Replace("||", "");
|
||||
sapisid = Uri.UnescapeDataString(sapisid);
|
||||
if (string.IsNullOrWhiteSpace(time))
|
||||
|
Reference in New Issue
Block a user