From bb1dd4ecfd8a0f7bcc024cb5e049397c1aa2a80b Mon Sep 17 00:00:00 2001 From: Achim Date: Sat, 9 Mar 2024 10:16:54 +0100 Subject: [PATCH] Inject Private Access Token as optional request param It turned out: If the parameter `private_token` is given but empty, the Gitlab REST API does expect a valid access token otherwise responds with an authorization error --- lib/app_sources/gitlab.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/app_sources/gitlab.dart b/lib/app_sources/gitlab.dart index df200f7..cf33826 100644 --- a/lib/app_sources/gitlab.dart +++ b/lib/app_sources/gitlab.dart @@ -112,10 +112,11 @@ class GitLab extends AppSource { // Prepare request params var names = GitHub().getAppNames(standardUrl); String? PAT = await getPATIfAny(hostChanged ? additionalSettings : {}); + String optionalAuth = (PAT != null) ? 'private_token=$PAT' : ''; // Request data from REST API Response res = await sourceRequest( - 'https://${hosts[0]}/api/v4/projects/${names.author}%2F${names.name}/releases?private_token=$PAT', + 'https://${hosts[0]}/api/v4/projects/${names.author}%2F${names.name}/releases?$optionalAuth', additionalSettings); if (res.statusCode != 200) { throw getObtainiumHttpError(res);