Added new method for auth headers
This commit is contained in:
parent
ab96b227a1
commit
c058a35abe
|
|
@ -87,7 +87,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||
set
|
||||
{
|
||||
_tubeArchivistApiKey = value;
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||
Plugin.Instance?.UpdateAuthorizationHeader();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||
handler.AllowAutoRedirect = false;
|
||||
handler.CheckCertificateRevocationList = true;
|
||||
HttpClient = new HttpClient(handler);
|
||||
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Instance?.Configuration.TubeArchivistApiKey);
|
||||
|
||||
UpdateAuthorizationHeader();
|
||||
|
||||
SessionManager = sessionManager;
|
||||
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
||||
LibraryManager = libraryManager;
|
||||
|
|
@ -128,6 +130,23 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Updates the HTTP client's Authorization header with the current API key.
|
||||
/// </summary>
|
||||
public void UpdateAuthorizationHeader()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Configuration.TubeArchivistApiKey))
|
||||
{
|
||||
HttpClient.DefaultRequestHeaders.Authorization =
|
||||
new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Configuration.TubeArchivistApiKey);
|
||||
Logger.LogInformation("{Message}", "Updated Authorization header with API key");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("{Message}", "No TubeArchivist API key configured");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the TubeArchivist API connection status.
|
||||
/// </summary>
|
||||
|
|
@ -207,4 +226,4 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue