Skip to content

Commit 8429811

Browse files
HerHdepat-s
andauthored
Fix Gitpod: Gitea auth token creation (#3299)
The Gitea CLI `generate-access-token` has updated the OAuth scopes and [posts some warning to the STDOUT when creating a token](go-gitea/gitea#28758): ``` .../setting/security.go:168:loadSecurityFrom() [W] Enabling Query API Auth tokens is not recommended. DISABLE_QUERY_AUTH_TOKEN will default to true in gitea 1.23 and will be removed in gitea 1.24. 0adftokenblablubb ``` When logging in to the Gitpod Gitea instance from Woodpecker, I get an error: ![Authorization failed: Client ID not registered](https://github.com/woodpecker-ci/woodpecker/assets/7630662/bd28a661-d46e-4691-aff7-a25d64f8e7ce) This PR fixes the problems leading you to a dialogue authorizing Woodpecker after logging in to Gitea. --------- Co-authored-by: Patrick Schratz <[email protected]>
1 parent 9df572e commit 8429811

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

.gitpod.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ tasks:
4242
$DOCKER_COMPOSE_CMD up -d
4343
until curl --output /dev/null --silent --head --fail http://localhost:3000; do printf '.'; sleep 1; done
4444
$GITEA_CLI_CMD admin user create --username woodpecker --password password --email woodpecker@localhost --admin
45-
export GITEA_TOKEN=$($GITEA_CLI_CMD admin user generate-access-token -u woodpecker --scopes repo,write:application --raw)
45+
export GITEA_TOKEN=$($GITEA_CLI_CMD admin user generate-access-token -u woodpecker --scopes write:repository,write:user --raw | tail -n 1 | awk 'NF{ print $NF }')
4646
GITEA_OAUTH_APP=$(curl -X 'POST' 'http://localhost:3000/api/v1/user/applications/oauth2' \
4747
-H 'accept: application/json' -H 'Content-Type: application/json' -H "Authorization: token ${GITEA_TOKEN}" \
4848
-d "{ \"name\": \"Woodpecker CI\", \"confidential_client\": true, \"redirect_uris\": [ \"https://8000-${GITPOD_WORKSPACE_ID}.${GITPOD_WORKSPACE_CLUSTER_HOST}/authorize\" ] }")
49+
touch .env
4950
grep "WOODPECKER_GITEA_CLIENT=" .env \
5051
&& sed "s,^WOODPECKER_GITEA_CLIENT=.*,WOODPECKER_GITEA_CLIENT=$(echo $GITEA_OAUTH_APP | jq -r .client_id)," .env \
5152
|| echo WOODPECKER_GITEA_CLIENT=$(echo $GITEA_OAUTH_APP | jq -r .client_id) >> .env

0 commit comments

Comments
 (0)