Added new method for auth headers
This commit is contained in:
@@ -87,7 +87,8 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Configuration
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
_tubeArchivistApiKey = value;
|
_tubeArchivistApiKey = value;
|
||||||
Plugin.Instance?.LogTAApiConnectionStatus();
|
Plugin.Instance?.LogTAApiConnectionStatus();
|
||||||
|
Plugin.Instance?.UpdateAuthorizationHeader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
handler.AllowAutoRedirect = false;
|
handler.AllowAutoRedirect = false;
|
||||||
handler.CheckCertificateRevocationList = true;
|
handler.CheckCertificateRevocationList = true;
|
||||||
HttpClient = new HttpClient(handler);
|
HttpClient = new HttpClient(handler);
|
||||||
HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", Instance?.Configuration.TubeArchivistApiKey);
|
|
||||||
|
UpdateAuthorizationHeader();
|
||||||
|
|
||||||
SessionManager = sessionManager;
|
SessionManager = sessionManager;
|
||||||
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
sessionManager.PlaybackProgress += OnPlaybackProgress;
|
||||||
LibraryManager = libraryManager;
|
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>
|
/// <summary>
|
||||||
/// Logs the TubeArchivist API connection status.
|
/// Logs the TubeArchivist API connection status.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -207,4 +226,4 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user