Files
LeagueARAMTracker/LeagueAPI/RiotAuthentication.cs
2026-03-08 20:45:01 +01:00

49 lines
1.3 KiB
C#

using System.Net;
using System.Net.Http.Headers;
using System.Text;
namespace LeagueAPI;
/// <summary>
/// Repesents authentication for the League Client.
/// </summary>
/// <param name="RemotingAuthToken"></param>
public class RiotAuthentication(string RemotingAuthToken)
{
/// <summary>
/// Username component of the authentication;
/// </summary>
public string Username { get; } = "riot";
/// <summary>
/// Password component of the authentication.
/// </summary>
public string Password { get; } = RemotingAuthToken;
/// <summary>
/// Authentication value before Base64 conversion.
/// </summary>
public string RawValue => Username + ":" + Password;
/// <summary>
/// Authentication value in Base64 format.
/// </summary>
public string Value => Convert.ToBase64String(Encoding.UTF8.GetBytes(RawValue));
/// <summary>
/// Get an AuthenticationHeaderValue instance.
/// </summary>
public AuthenticationHeaderValue ToAuthenticationHeaderValue()
{
return new AuthenticationHeaderValue("Basic", Value);
}
/// <summary>
/// Get an NetworkCredential instance.
/// </summary>
public NetworkCredential ToNetworkCredential()
{
return new NetworkCredential(Username, Password);
}
}