Allow prebaked application token in environment variables #5821

Closed
opened 2025-11-02 06:36:50 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @izelnakri on GitHub (Aug 3, 2020).

Hi there,

I know that gitea currently provides a UI to generate application tokens. However it also needs one application token(a master API key/token perhaps) as environment variable, this way I can deploy gitea in an automated fashion without utilizing the UI.

In addition, in my own situation I built a microservice that interacts with gitea over webhooks(it posts CI jobs, and makes PR comments on CI running/results), this microservice/k8s deployment uses $GITEA_SERVER_TOKEN env variable to interact with the gitea API(to post a PR comment, get open PRs etc). Therefore, this makes the current deployment very challenging without having a prebaked/predetermined application master API token, as that deployment needs to be restarted with the application token in the environment variable when I generate it from the UI currently. Having one token as an environment variable can solve all these problems.

Originally created by @izelnakri on GitHub (Aug 3, 2020). Hi there, I know that gitea currently provides a UI to generate application tokens. However it also needs one application token(a master API key/token perhaps) as environment variable, this way I can deploy gitea in an automated fashion without utilizing the UI. In addition, in my own situation I built a microservice that interacts with gitea over webhooks(it posts CI jobs, and makes PR comments on CI running/results), this microservice/k8s deployment uses `$GITEA_SERVER_TOKEN` env variable to interact with the gitea API(to post a PR comment, get open PRs etc). Therefore, this makes the current deployment very challenging without having a prebaked/predetermined application master API token, as that deployment needs to be restarted with the application token in the environment variable when I generate it from the UI currently. Having one token as an environment variable can solve all these problems.
GiteaMirror added the issue/needs-feedback label 2025-11-02 06:36:50 -06:00
Author
Owner

@lunny commented on GitHub (Aug 4, 2020):

You can create a token at first via API.

@lunny commented on GitHub (Aug 4, 2020): You can create a token at first via API.
Author
Owner

@izelnakri commented on GitHub (Aug 4, 2020):

POST /users/{username}/token requires an authentication token, it gives 401. How can I generate a token without an authentication token?

@izelnakri commented on GitHub (Aug 4, 2020): POST /users/{username}/token requires an authentication token, it gives 401. How can I generate a token without an authentication token?
Author
Owner

@zeripath commented on GitHub (Aug 4, 2020):

POST /user/{username}/token requires BASIC authentication not Token.

@zeripath commented on GitHub (Aug 4, 2020): POST /user/{username}/token requires BASIC authentication not Token.
Author
Owner

@izelnakri commented on GitHub (Aug 4, 2020):

@zeripath this works, thank you! Let's also document it, closing this issue.

@izelnakri commented on GitHub (Aug 4, 2020): @zeripath this works, thank you! Let's also document it, closing this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5821