From ea4e4aa00a3ed30ce007943aaad84659b028ad59 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 11 Feb 2024 14:12:48 -0500 Subject: [PATCH] fix: support both auth token and oauth token --- api/routes.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/routes.go b/api/routes.go index 0469813..cc23744 100644 --- a/api/routes.go +++ b/api/routes.go @@ -39,10 +39,17 @@ type ClientParams struct { func getClient(params ClientParams) (*gitea.Client, error) { options := make([]gitea.ClientOption, 0) + authToken := "" if len(params.AuthToken) > 0 { - options = append(options, gitea.SetToken(params.AuthToken)) + authToken = params.AuthToken } + if len(authToken) == 0 { + authToken = params.Config.Oauth.Token + } + + options = append(options, gitea.SetToken(authToken)) + client, err := gitea.NewClient(params.Config.GiteaUrl, options...) if err != nil { return nil, err