From 2dc70ac27c0e1b54eba0c46af432ed1ac4b15a51 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Sat, 13 Apr 2024 11:06:23 +0200 Subject: [PATCH] feat(gitea)!: use `Bearer` instead of `token` for auth (#28308) Co-authored-by: Rhys Arkins Co-authored-by: Sebastian Poxhofer --- lib/util/http/auth.spec.ts | 2 +- lib/util/http/auth.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/util/http/auth.spec.ts b/lib/util/http/auth.spec.ts index 2854af307c1389..208a8209b67da1 100644 --- a/lib/util/http/auth.spec.ts +++ b/lib/util/http/auth.spec.ts @@ -57,7 +57,7 @@ describe('util/http/auth', () => { expect(opts).toMatchInlineSnapshot(` { "headers": { - "authorization": "token XXXX", + "authorization": "Bearer XXXX", }, "hostType": "gitea", "token": "XXXX", diff --git a/lib/util/http/auth.ts b/lib/util/http/auth.ts index 99cc9bec817651..0beec921d901c9 100644 --- a/lib/util/http/auth.ts +++ b/lib/util/http/auth.ts @@ -40,7 +40,9 @@ export function applyAuthorization( options.hostType && GITEA_API_USING_HOST_TYPES.includes(options.hostType) ) { - options.headers.authorization = `token ${options.token}`; + // Gitea v1.8.0 and later support `Bearer` as alternate to `token` + // https://github.com/go-gitea/gitea/pull/5378 + options.headers.authorization = `Bearer ${options.token}`; } else if ( options.hostType && GITHUB_API_USING_HOST_TYPES.includes(options.hostType)