Auth with Forgejo Tokens

This is how you can push to Codeberg without entering your login password.

Steps

  1. Generate an access token on your Forgejo instance for your account.

  2. Before generating token, optionally select permissions for your token.

  3. Copy your token and keep it somewhere safe. It will not be shown again!

  4. Now you can commit with username oauth2 and your token as password:

    $ git commit -m 'fixes'
    $ git push
    Username for 'https://codeberg.org': oauth2
    Password for 'https://codeberg.org': <paste your token>
    
  5. You can also clone your repository with the token:

    $ git clone https://oauth2:<token>@codeberg.org/user/repo.git
    

    This way, auth isn’t needed when pushing to this repository.
    You can also modify the URL in .git/config of existing local repositories.

  6. Tokens can also be used for automation and oauth2 solutions. Be sure to generate dedicated tokens for each service.

Note

Despite the token is not your login password, it still needs to be keeped secret, and be regenerated in case of potential leakage. No warranty!